Hi, Im Using GWT + AppEng is that the problem here? Lets say I have an existing database which I want to use for my GWT application what is the possible solution you reckon ?
On Tue, Sep 22, 2009 at 7:08 AM, Sripathi Krishnan < [email protected]> wrote: > If you are using Google App Engine (separate from GWT), you *cannot* use > an external database. App Engine doesn't allow you to open socket > connections, and that is exactly what the getConnection() method does. > > --Sri > > > 2009/9/21 Chamira Fernando <[email protected]> > > >> Hi All, >> >> I have the same problem when I connect to MySQL database, >> >> What I understand from the GWT doc, whatever server side scripts we >> have to in .server package and this will be on server side on host >> mode when we debug the application. >> >> here is the scenario >> >> I can get the data from the server side if there is no database >> connection, everything works fine, the moment I run database >> connection method >> >> I get errors! narrowing the problem i tried to load the class >> (Class.forName(DRIVER)) only.. it seems class is loaded (i get no >> errors) but the moment I run >> connection = DriverManager.getConnection(URL,USER,PASS); method will >> cause the problem .. if this is an sql error, should be caught ?? >> >> mind you >> my mysql connector is in proper dirs (otherwise I can't load DRIVER ). >> >> Do I need to set $catalina.home for hosted mode? then can someone help >> to do it (im using eclipse plugin) >> >> Can someone come up with an answer, prefer small script to >> understand... >> >> here is the stack trace I got >> >> Sep 21, 2009 12:05:02 PM >> com.google.appengine.tools.development.ApiProxyLocalImpl log >> SEVERE: [1253534702085000] javax.servlet.ServletContext log: Exception >> while dispatching incoming RPC call >> com.google.gwt.user.server.rpc.UnexpectedException: Service method >> 'public abstract java.lang.String >> com.pro.student.client.GreetingService.greetServer(java.lang.String)' >> threw an unexpected exception: java.lang.ExceptionInInitializerError >> at com.google.gwt.user.server.rpc.RPC.encodeResponseForFailure >> (RPC.java:360) >> at com.google.gwt.user.server.rpc.RPC.invokeAndEncodeResponse >> (RPC.java:546) >> at com.google.gwt.user.server.rpc.RemoteServiceServlet.processCall >> (RemoteServiceServlet.java:166) >> at com.google.gwt.user.server.rpc.RemoteServiceServlet.doPost >> (RemoteServiceServlet.java:86) >> at javax.servlet.http.HttpServlet.service(HttpServlet.java:713) >> at javax.servlet.http.HttpServlet.service(HttpServlet.java:806) >> at >> org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java: >> 487) >> at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter >> (ServletHandler.java:1093) >> at >> com.google.apphosting.utils.servlet.TransactionCleanupFilter.doFilter >> (TransactionCleanupFilter.java:43) >> at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter >> (ServletHandler.java:1084) >> at com.google.appengine.tools.development.StaticFileFilter.doFilter >> (StaticFileFilter.java:121) >> at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter >> (ServletHandler.java:1084) >> at org.mortbay.jetty.servlet.ServletHandler.handle >> (ServletHandler.java:360) >> at org.mortbay.jetty.security.SecurityHandler.handle >> (SecurityHandler.java:216) >> at org.mortbay.jetty.servlet.SessionHandler.handle >> (SessionHandler.java:181) >> at org.mortbay.jetty.handler.ContextHandler.handle >> (ContextHandler.java:712) >> at >> org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java: >> 405) >> at >> com.google.apphosting.utils.jetty.DevAppEngineWebAppContext.handle >> (DevAppEngineWebAppContext.java:54) >> at org.mortbay.jetty.handler.HandlerWrapper.handle >> (HandlerWrapper.java:139) >> at com.google.appengine.tools.development.JettyContainerService >> $ApiProxyHandler.handle(JettyContainerService.java:313) >> at org.mortbay.jetty.handler.HandlerWrapper.handle >> (HandlerWrapper.java:139) >> at org.mortbay.jetty.Server.handle(Server.java:313) >> at >> org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java: >> 506) >> at org.mortbay.jetty.HttpConnection$RequestHandler.content >> (HttpConnection.java:844) >> at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:644) >> at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:211) >> at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:381) >> at org.mortbay.io.nio.SelectChannelEndPoint.run >> (SelectChannelEndPoint.java:396) >> at org.mortbay.thread.BoundedThreadPool$PoolThread.run >> (BoundedThreadPool.java:442) >> Caused by: java.lang.ExceptionInInitializerError >> at com.mysql.jdbc.NonRegisteringDriver.connect >> (NonRegisteringDriver.java:283) >> at java.sql.DriverManager.getConnection(DriverManager.java:525) >> at java.sql.DriverManager.getConnection(DriverManager.java:171) >> at com.pro.student.server.GreetingServiceImpl.db >> (GreetingServiceImpl.java:52) >> at com.pro.student.server.GreetingServiceImpl.greetServer >> (GreetingServiceImpl.java:23) >> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) >> at sun.reflect.NativeMethodAccessorImpl.invoke >> (NativeMethodAccessorImpl.java:39) >> at sun.reflect.DelegatingMethodAccessorImpl.invoke >> (DelegatingMethodAccessorImpl.java:25) >> at java.lang.reflect.Method.invoke(Method.java:592) >> at com.google.gwt.user.server.rpc.RPC.invokeAndEncodeResponse >> (RPC.java:527) >> ... 27 more >> Caused by: java.security.AccessControlException: access denied >> (java.lang.RuntimePermission modifyThreadGroup) >> at java.security.AccessControlContext.checkPermission >> (AccessControlContext.java:264) >> at java.security.AccessController.checkPermission >> (AccessController.java:427) >> at java.lang.SecurityManager.checkPermission(SecurityManager.java: >> 532) >> at com.google.appengine.tools.development.DevAppServerFactory >> $CustomSecurityManager.checkPermission(DevAppServerFactory.java:139) >> at com.google.appengine.tools.development.DevAppServerFactory >> $CustomSecurityManager.checkAccess(DevAppServerFactory.java:166) >> at java.lang.ThreadGroup.checkAccess(ThreadGroup.java:288) >> at java.lang.Thread.init(Thread.java:310) >> at java.lang.Thread.<init>(Thread.java:358) >> at java.util.TimerThread.<init>(Timer.java:456) >> at java.util.Timer.<init>(Timer.java:71) >> at java.util.Timer.<init>(Timer.java:122) >> at com.mysql.jdbc.ConnectionImpl.<clinit>(ConnectionImpl.java:208) >> ... 37 more >> >> >> >> >> >> On Sep 3, 7:21 am, GumbyGWTBeginner <[email protected]> wrote: >> > Hi Guys, >> > >> > Was wondering if anyone could answer a small question? >> > >> > I have created a class called DBFlow (Code below) which connects to >> > aMySQLDB and retrieve the number of rows in a DB. >> > >> > I am new at this could anyone throw some light on the subject. >> > >> > ****************Error Message**************** >> > >> > [ERROR] Line 51: The method forName(String) is undefined for the type >> > Class >> > >> > ****************Code to Call Class**************** >> > >> > DBFlow TestTheDB = new DBFlow(); >> > TestTheDB.main(); >> > >> > ****************Class Code**************** >> > >> > import java.sql.Connection; >> > import java.sql.DriverManager; >> > import java.sql.ResultSet; >> > import java.sql.SQLException; >> > import java.sql.Statement; >> > import java.lang.Class; >> > import com.google.gwt.user.client.Window; >> > >> > public class DBFlow { >> > >> > public void onModuleLoad() { >> > //sdsd >> > >> > } >> > >> > public DBFlow() { >> > //sdsd >> > >> > } >> > >> > public void main() { >> > Connectionconn = null; >> > try { >> > conn = getConnection(); >> > String tableName = "family"; >> > Window.alert("tableName=" + tableName); >> > Window.alert("conn=" + conn); >> > Window.alert("rowCount=" + countRows(conn, >> tableName)); >> > } catch (Exception e) { >> > Window.alert("No Connect"); >> > e.printStackTrace(); >> > //System.exit(1); // Edit out as it is an erro >> > } finally { >> > // releasedatabaseresources >> > try { >> > conn.close(); >> > } catch (SQLException e) { >> > e.printStackTrace(); >> > } >> > } >> > } >> > >> > publicConnectiongetConnection() throws Exception { >> > String driver = "com.mysql.jdbc.Driver"; >> > String url = "jdbc:mysql://localhost:3306/dogs"; >> > String username = "root"; >> > String password = "mypass"; >> > >> > Class.forName(driver); // loadMySQLdriver >> > ***************************************Error here apprantly >> > Connectionconn = DriverManager.getConnection(url, >> username, >> > password); >> > return conn; >> > } >> > >> > public int countRows(Connectionconn, String tableName) throws >> > SQLException { >> > // select the number of rows in the table >> > Statement stmt = null; >> > ResultSet rs = null; >> > int rowCount = -1; >> > try { >> > stmt = conn.createStatement(); >> > rs = stmt.executeQuery("SELECT COUNT(*) FROM " + >> tableName); >> > // get the number of rows from the result set >> > rs.next(); >> > rowCount = rs.getInt(1); >> > } finally { >> > rs.close(); >> > stmt.close(); >> > } >> > return rowCount; >> > } >> > >> > >> > >> > } >> >> >> > > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en -~----------~----~----~----~------~----~------~--~---
