Thursday, November 26, 2015

Re: [google-cloud-sql-discuss] App Engine fetching data from google cloud instance very slow

This is my method in the class which establishes a database connection to Cloud SQL. The first method is the connection establishing method and the second method is a sample method I use during my RPC calls to fetch data from the database:
public void connect() throws ClassNotFoundException {
if (SystemProperty.environment.value() == SystemProperty.Environment.Value.Production) {
Class.forName("com.mysql.jdbc.GoogleDriver");
url = "jdbc:google:mysql://moviedatabase-1113:moviedatabase/moviedatabase?user=root";
} else {
Class.forName("com.mysql.jdbc.Driver");
url = "jdbc:mysql://localhost:3306/moviedatabase-neu?user=root";

}
}


/**
* fetches data from the database depending on the SQL query. Returns an
* arraylist of movie data instances in order to visualize them in different
* manners
*/
public List<DataRow> fetchData(String query) {
String SQLquery = query;
java.sql.ResultSet result = null;
ArrayList<DataRow> datarow = new ArrayList<DataRow>();

try {
this.connect();
Connection conn = DriverManager.getConnection(this.url, "root","root");
result = conn.createStatement().executeQuery(SQLquery);
int count = 0;
while (result.next()) {
datarow.add(new DataRow());
datarow.get(count).setWiki(result.getInt("WikipediaID"));
datarow.get(count).setFreebase(result.getString("FreebaseID"));
datarow.get(count).setName(result.getString("Name"));
datarow.get(count).setYear(result.getInt("Year"));
datarow.get(count).setRevenue(result.getInt("Revenue"));
datarow.get(count).setLength(result.getDouble("Length"));
datarow.get(count).setLanguage(cleanQuery(result.getString("Language")));
datarow.get(count).setCountry(cleanQuery(result.getString("Country")));
datarow.get(count).setGenre(cleanQuery(result.getString("Genre")));
count++;
}
} catch (SQLException e) {
e.printStackTrace();
} catch (ClassNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
/**
* returns arraylist of moviedata
*/
return datarow;
}


Did I forget to close established connections somewhere?
Thanks and Regards
Am Mittwoch, 25. November 2015 23:23:12 UTC+1 schrieb Razvan Musaloiu-E.:
An example is here:

https://cloud.google.com/appengine/docs/java/cloud-sql/

At the bottom there are some links to some more examples on GitHub.

-- Razvan ME

On Wed, Nov 25, 2015 at 2:21 PM, Kürsat Aydinli <kuersat...@uzh.ch> wrote:
How can I make sure the app is not leaking the Cloud Sql connection? Can I somehow reset my used connection? I didn´t get your answer I think

Am Mittwoch, 25. November 2015 23:16:40 UTC+1 schrieb Razvan Musaloiu-E.:
Can you please make sure the app is not leaking the Cloud SQL connections? Each GAE instance is not allowed to use more than 12 connections and the one I looked was already hitting that limit.

-- Razvan ME

On Wed, Nov 25, 2015 at 2:08 PM, Kürsat Aydinli <kuersat...@uzh.ch> wrote:
This is my connection link:
url = "jdbc:google:mysql://moviedatabase-1113:moviedatabase/moviedatabase?user=root";

Am Mittwoch, 25. November 2015 22:55:48 UTC+1 schrieb Razvan Musaloiu-E.:
How are you connecting to Cloud SQL from GAE? Are you using a JDBC URL that has a 'jdbc:google:mysql://' prefix?

-- Razvan ME

On Wed, Nov 25, 2015 at 1:50 PM, Kürsat Aydinli <kuersat...@uzh.ch> wrote:
Hi,

I have written a GWT App which visualizes moviedata (database with 80000 rows/entries) on the Web in different manners (Table, Worldmap, Piechart, Columnchart). For my local development I use Wamp Server and local MySQL database which works really fine and fast. But when I host the App to GAE (using same database which is on Google Cloud SQL) the fetching time from the database is very slow...it even seems to crash after 1 minute. After the first deployment of the App to GAE the App seems to work, but when I try to reload or filter the table view of the data, the connection to Google Cloud Sql seems to crash.

My App is authorized on Google Cloud and has access to my database on Google CLoud SQL. But After I use my App for like 1 minute the database connections seems to be interrupted.
I have gone through every possible setting opportunities on Google Developers.

Could you please give me some help or advice? If needed, I can post my App Engine Link for you to try out the App.

Thanks and Kind Regards

--
You received this message because you are subscribed to the Google Groups "Google Cloud SQL discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-cloud-sql-discuss+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-cloud-sql-discuss/4fbb6c80-2975-46ab-a269-df95bda66928%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Google Cloud SQL discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-cloud-sql-discuss+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-cloud-sql-discuss/3dc6416f-ada2-4925-b1fc-fe12f20d0cee%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Google Cloud SQL discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-cloud-sql-discuss+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-cloud-sql-discuss/6e481a4e-9e0b-4106-a1f7-e721f75ae702%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Google Cloud SQL discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-cloud-sql-discuss+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-cloud-sql-discuss/0438705e-5e60-46ef-b562-693961e800cd%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment