Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I have created a cloud sql instance in a PHP project and have made the billing procedure successfully. The project works.

Now, I want to access my database from another project but this time in Java SDK project with servlets. Using the example in https://developers.google.com/appengine/ docs/java/cloud-sql/

In Java project I have:

project id: javaProjectID

In php project id I have: project id: phptestID instance name: phpinstanceName

database: dbname

In my code in Servlet i do the below connection:

String url = "jdbc:google:mysql://phptestID:phpinstanceName/dbname?user=root";
Connection conn = (Connection) DriverManager.getConnection(url);

(...>> The connection fails in this point and doesn't access the database to make the below query )

String sqlStmt = "SELECT * FROM  sometable";
PreparedStatement  stmt = conn.prepareStatement(sqlStmt);
ResultSetres = stmt.executeQuery(sqlStmt);

How can I access my database in another project?? Is there any other way except your-project-id:your-instance-name???

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
1.0k views
Welcome To Ask or Share your Answers For Others

1 Answer

Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share

548k questions

547k answers

4 comments

86.3k users

...