Hello, I want to connect to a mysql server from the server side of my GWT
code, like this:
>
> @SuppressWarnings("serial")
>
> public class CommunicationServiceImpl extends RemoteServiceServlet
> implements
>
> CommunicationService
>
> {
>
> @Override
>
> public UserLogin communicationServer(UserLogin user)
>
> {
>
> String hash = BCrypt.hashpw(user.password, BCrypt.gensalt());
>
> user.password = hash;
>
> query();
>
> return user;
>
> }
>
> public void query()
>
> {
>
> String username = "root";
>
> String password = "root";
>
> String driver = "com.mysql.jdbc.Driver";
>
> String url = "jdbc:mysql://localhost:8889/User";
>
> Connection conn = null;
>
> try
>
> {
>
> Class.forName(driver);
>
> conn = DriverManager.getConnection(url,username,password);
>
> System.out.println("FOUND DRIVER");
>
> }
>
> catch(Exception e)
>
> {
>
> e.printStackTrace();
>
> System.out.println("ERROR CONNECTING USER");
>
> }
>
> try
>
> {
>
> Statement stmt = conn.createStatement();
>
> String sql = "SELECT Username FROM UserInformation";
>
> ResultSet result = stmt.executeQuery(sql);
>
> System.out.println("TRY TO EXECUTE QUERY");
>
> while(result.next())
>
> {
>
> System.out.println(result.getString("Username"));
>
> }
>
> }
>
> catch(Exception e)
>
> {
>
> e.printStackTrace();
>
> }
>
> }
>
> }
>
>>
>>
But when I run the code, I get this error:
SCHWERWIEGEND: javax.servlet.ServletContext log: Exception while
dispatching incoming RPC call
com.google.gwt.user.server.rpc.UnexpectedException: Service method 'public
abstract de.mapJobs.jltech.shared.UserLogin
de.mapJobs.jltech.client.CommunicationService.communicationServer(de.mapJobs.jltech.shared.UserLogin)'
threw an unexpected exception: java.lang.ExceptionInInitializerError
at com.google.gwt.user.server.rpc.RPC.encodeResponseForFailure(RPC.java:385)
at com.google.gwt.user.server.rpc.RPC.invokeAndEncodeResponse(RPC.java:588)
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.tools.development.HeaderVerificationFilter.doFilter(
HeaderVerificationFilter.java:35)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(
ServletHandler.java:1157)
at com.google.appengine.api.blobstore.dev.ServeBlobFilter.doFilter(
ServeBlobFilter.java:60)
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:125)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(
ServletHandler.java:1157)
at com.google.appengine.tools.development.BackendServersFilter.doFilter(
BackendServersFilter.java:97)
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.appengine.tools.development.DevAppEngineWebAppContext.handle(
DevAppEngineWebAppContext.java:94)
at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
at
com.google.appengine.tools.development.JettyContainerService$ApiProxyHandler.handle(
JettyContainerService.java:370)
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.lang.ExceptionInInitializerError
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:169)
at de.mapJobs.jltech.server.CommunicationServiceImpl.query(
CommunicationServiceImpl.java:40)
at de.mapJobs.jltech.server.CommunicationServiceImpl.communicationServer(
CommunicationServiceImpl.java:24)
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:115)
at com.google.gwt.user.server.rpc.RPC.invokeAndEncodeResponse(RPC.java:569)
... 34 more
Caused by: java.security.AccessControlException: access denied
(java.lang.RuntimePermission modifyThreadGroup)
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:283)
at
com.google.appengine.tools.development.DevAppServerFactory$CustomSecurityManager.checkAccess(
DevAppServerFactory.java:308)
at java.lang.ThreadGroup.checkAccess(ThreadGroup.java:299)
at java.lang.Thread.init(Thread.java:336)
at java.lang.Thread.<init>(Thread.java:472)
at com.mysql.jdbc.NonRegisteringDriver$1.<init>(NonRegisteringDriver.java:90
)
at com.mysql.jdbc.NonRegisteringDriver.<clinit>(NonRegisteringDriver.java:89
)
> ... 44 more
Any solutions for this problem?
--
You received this message because you are subscribed to the Google Groups
"Google Web Toolkit" group.
To view this discussion on the web visit
https://groups.google.com/d/msg/google-web-toolkit/-/fJ5481AL7mwJ.
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.