Hi David, 
If using mysql then your not planning on using app engine to depoly? If not i'f 
say get rid of it from the project. The other thing is are you calling the jdbc 
server side, through RPC, I'm confident thats how to go about it. 
Regards, John. 

Sent from my iPhone

On 24 Apr 2011, at 14:45, David <davidgmah...@gmail.com> wrote:

> Hi,
> 
> This is my first coding post so hopefully Im doing things the right
> way..
> 
> I am developing a gwt app where I need mySQL connection. I think I
> have grasped the whole client server thing ( RMI etc ).
> 
> In my server side code I am trying to establish a database connection
> to mySQL using the JDBC driver. The errors are below. My setup is as
> follows
> 
> OS: Ubuntu
> GWT: GWT 2.2.0
> SERVER: LAMP ( linux apache mySQL python )
> 
> Part of my application includes an Android app which communicates with
> the mySQL via a php script passing the data to JSON.
> 
> Can anyone help with my errors? I have a feeling it may be something
> to do with SOP ( single origin policy? ) . The code and error is
> below.. Thanks.
> 
> public class MySQLConnection  {
> 
> 
>        private Connection conn = null;
>        private String status;
>        private String url  = "jdbc:mysql://localhost:3306/javabase";
>        private String user = "java";
>        private String pass = "d$7hF_r!9Y";
>        public MySQLConnection() {
> 
>            Logger logger = Logger.getLogger("NameOfYourLogger");
>            logger.log(Level.SEVERE, "Good one. you made it to MYSQL
> CONN!" );
>            System.out.println("Good one. you made it to tmysql conn");
>            try {
>                System.out.println("Loading driver...");
>                Class.forName("com.mysql.jdbc.Driver");
>                System.out.println("Driver loaded!");
>            } catch (ClassNotFoundException e) {
>                throw new RuntimeException("Cannot find the driver in the
> classpath!", e);
>            }
> 
>                try {
> 
> Class.forName("com.mysql.jdbc.Driver").newInstance();
>                        conn = DriverManager.getConnection(url, user,
> pass);
>                        //conn =
> DriverManager.getConnection( "jdbc:mysql://localhost/my_test_db?
> user=root&password=083c3acak3");
> 
>                        Logger loggers =
> Logger.getLogger("NameOfYourLogger");
>                        loggers.log(Level.SEVERE, "We got DB connection!" );
>                } catch (Exception e) {
>                    String messageOut = "Unable to connect to database.
> Exception message: " + e.getMessage();
>                    System.out.println(messageOut);
>                    e.printStackTrace();
>                    // Server side log
>                    //loggers.error(messageOut + "\n", e);
>                    Logger loggers =
> Logger.getLogger("NameOfYourLogger");
>                    loggers.log(Level.SEVERE, "BUT were caught in an
> exeption" );
>                        //NEVER catch exceptions like this
>                }
>        }
> }
> 
> Unable to connect to database. Exception message: Could not create
> connection to database server.
> com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException:
> Could not create connection to database server.
>    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native
> Method)
>    at
> sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:
> 39)
>    at
> sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:
> 27)
>    at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
>    at
> com.google.appengine.tools.development.agent.runtime.Runtime.newInstance_(Runtime.java:
> 112)
>    at
> com.google.appengine.tools.development.agent.runtime.Runtime.newInstance(Runtime.java:
> 120)
>    at com.mysql.jdbc.Util.handleNewInstance(Util.java:407)
>    at com.mysql.jdbc.Util.getInstance(Util.java:382)
>    at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1013)
>    at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:987)
>    at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:982)
>    at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:927)
>    at
> com.mysql.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:
> 2413)
>    at com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:
> 2163)
>    at com.mysql.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:794)
>    at com.mysql.jdbc.JDBC4Connection.<init>(JDBC4Connection.java:47)
>    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native
> Method)
>    at
> sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:
> 39)
>    at
> sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:
> 27)
>    at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
>    at
> com.google.appengine.tools.development.agent.runtime.Runtime.newInstance_(Runtime.java:
> 112)
>    at
> com.google.appengine.tools.development.agent.runtime.Runtime.newInstance(Runtime.java:
> 120)
>    at com.mysql.jdbc.Util.handleNewInstance(Util.java:407)
>    at com.mysql.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:378)
>    at
> com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:
> 305)
>    at java.sql.DriverManager.getConnection(DriverManager.java:582)
>    at java.sql.DriverManager.getConnection(DriverManager.java:185)
>    at org.hanson.gwt.server.MySQLConnection.<init>(MySQLConnection.java:
> 40)
>    at org.hanson.gwt.server.MyServiceImpl.myMethod(MyServiceImpl.java:
> 10)
>    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:597)
>    at
> com.google.appengine.tools.development.agent.runtime.Runtime.invoke(Runtime.java:
> 100)
>    at
> com.google.gwt.user.server.rpc.RPC.invokeAndEncodeResponse(RPC.java:
> 569)
>    at
> com.google.gwt.user.server.rpc.RemoteServiceServlet.processCall(RemoteServiceServlet.java:
> 208)
>    at
> com.google.gwt.user.server.rpc.RemoteServiceServlet.processPost(RemoteServiceServlet.java:
> 248)
>    at
> com.google.gwt.user.server.rpc.AbstractRemoteServiceServlet.doPost(AbstractRemoteServiceServlet.java:
> 62)
>    at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
>    at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
>    at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:
> 511)
>    at org.mortbay.jetty.servlet.ServletHandler
> $CachedChain.doFilter(ServletHandler.java:1166)
>    at
> com.google.appengine.api.blobstore.dev.ServeBlobFilter.doFilter(ServeBlobFilter.java:
> 58)
>    at org.mortbay.jetty.servlet.ServletHandler
> $CachedChain.doFilter(ServletHandler.java:1157)
>    at
> com.google.apphosting.utils.servlet.TransactionCleanupFilter.doFilter(TransactionCleanupFilter.java:
> 43)
>    at org.mortbay.jetty.servlet.ServletHandler
> $CachedChain.doFilter(ServletHandler.java:1157)
>    at
> com.google.appengine.tools.development.StaticFileFilter.doFilter(StaticFileFilter.java:
> 122)
>    at org.mortbay.jetty.servlet.ServletHandler
> $CachedChain.doFilter(ServletHandler.java:1157)
>    at
> org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:
> 388)
>    at
> org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:
> 216)
>    at
> org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:
> 182)
>    at
> org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:
> 765)
>    at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:
> 418)
>    at
> com.google.apphosting.utils.jetty.DevAppEngineWebAppContext.handle(DevAppEngineWebAppContext.java:
> 70)
>    at
> org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:
> 152)
>    at com.google.appengine.tools.development.JettyContainerService
> $ApiProxyHandler.handle(JettyContainerService.java:351)
>    at
> org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:
> 152)
>    at org.mortbay.jetty.Server.handle(Server.java:326)
>    at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:
> 542)
>    at org.mortbay.jetty.HttpConnection
> $RequestHandler.content(HttpConnection.java:938)
>    at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:755)
>    at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:218)
>    at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)
>    at
> org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:
> 409)
>    at org.mortbay.thread.QueuedThreadPool
> $PoolThread.run(QueuedThreadPool.java:582)
> Caused by: java.security.AccessControlException: access denied
> (java.net.SocketPermission localhost resolve)
>    at
> java.security.AccessControlContext.checkPermission(AccessControlContext.java:
> 374)
>    at
> java.security.AccessController.checkPermission(AccessController.java:
> 546)
>    at java.lang.SecurityManager.checkPermission(SecurityManager.java:
> 532)
>    at com.google.appengine.tools.development.DevAppServerFactory
> $CustomSecurityManager.checkPermission(DevAppServerFactory.java:166)
>    at java.lang.SecurityManager.checkConnect(SecurityManager.java:1031)
>    at java.net.InetAddress.getAllByName0(InetAddress.java:1146)
>    at java.net.InetAddress.getAllByName(InetAddress.java:1084)
>    at java.net.InetAddress.getAllByName(InetAddress.java:1020)
>    at
> com.mysql.jdbc.StandardSocketFactory.connect(StandardSocketFactory.java:
> 244)
>    at com.mysql.jdbc.MysqlIO.<init>(MysqlIO.java:295)
>    at com.mysql.jdbc.ConnectionImpl.coreConnect(ConnectionImpl.java:
> 2334)
>    at
> com.mysql.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:
> 2371)
>    ... 52 more
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Google Web Toolkit" group.
> To post to this group, send email to google-web-toolkit@googlegroups.com.
> To unsubscribe from this group, send email to 
> google-web-toolkit+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/google-web-toolkit?hl=en.
> 

-- 
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To post to this group, send email to google-web-toolkit@googlegroups.com.
To unsubscribe from this group, send email to 
google-web-toolkit+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-web-toolkit?hl=en.

Reply via email to