This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes JDBC and the fly likes MySQl with Eclipse3.2 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "MySQl with Eclipse3.2" Watch "MySQl with Eclipse3.2" New topic
Author

MySQl with Eclipse3.2

Rakesh Mehra
Ranch Hand

Joined: Nov 20, 2007
Posts: 31
installed setup:eclipse3.2,tomcatplugin configured with eclipse3.2 successfully,mysql 5.0 also configured with eclipse 3.2 troough sqlexplorer plugin.

the problem is as follows:
trying jdbc using eclipse3.2

saple code:
res.setContentType("text/html");
PrintWriter out = res.getWriter();
try{
Class.forName("org.gjt.mm.mysql.Driver");
conn = DriverManager.getConnection("jdbc:mysql://localhost/test","root","password");
stmt = conn.createStatement();
rs = stmt.executeQuery("SELECT usrname,password FROM login");


on executing the class file containg the above code i get below error:

SQLException caught: Communications link failure due to underlying exception: ** BEGIN NESTED EXCEPTION ** java.net.SocketException MESSAGE: java.security.AccessControlException: access denied (java.net.SocketPermission 127.0.0.1:3306 connect,resolve) STACKTRACE: java.net.SocketException: java.security.AccessControlException: access denied (java.net.SocketPermission 127.0.0.1:3306 connect,resolve) at com.mysql.jdbc.StandardSocketFactory.unwrapExceptionToProperClassAndThrowIt(StandardSocketFactory.java:291) at com.mysql.jdbc.StandardSocketFactory.connect(StandardSocketFactory.java:182) at com.mysql.jdbc.MysqlIO.(MysqlIO.java:267) at com.mysql.jdbc.Connection.createNewIO(Connection.java:2739) at com.mysql.jdbc.Connection.(Connection.java:1553) at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:266) at java.sql.DriverManager.getConnection(Unknown Source) at java.sql.DriverManager.getConnection(Unknown Source) at com.Saveretrieve.doPost(Saveretrieve.java:20) at com.Saveretrieve.doGet(Saveretrieve.java:45) at javax.servlet.http.HttpServlet.service(HttpServlet.java:740) at javax.servlet.http.HttpServlet.service(HttpServlet.java:853) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247) at org.apache.catalina.core.ApplicationFilterChain.access$000(ApplicationFilterChain.java:98) at org.apache.catalina.core.ApplicationFilterChain$1.run(ApplicationFilterChain.java:176) at java.security.AccessController.doPrivileged(Native Method) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:172) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:256) at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480) at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191) at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480) at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995) at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2416) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180) at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643) at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:171) at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:172) at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480) at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:174) at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480) at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995) at org.apache.coyote.tomcat4.CoyoteAdapter.service(CoyoteAdapter.java:223) at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:601) at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:392) at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:565) at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:619) at java.lang.Thread.run(Unknown Source) ** END NESTED EXCEPTION ** Last packet sent to the server was 15 ms ago.
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14074
    
  16

Obviously the Java code that tries to make the connection does not have permission to connect to the database.

From where are you trying to connect to the database - from an applet? Note that applets have security restrictions; you can't create a network connection to any server from inside an applet.


Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 7 API documentation
Scala Notes - My blog about Scala
Rakesh Mehra
Ranch Hand

Joined: Nov 20, 2007
Posts: 31
Originally posted by Jesper Young:
Obviously the Java code that tries to make the connection does not have permission to connect to the database.

From where are you trying to connect to the database - from an applet? Note that applets have security restrictions; you can't create a network connection to any server from inside an applet.


STANDALONE servlet trying to access the local database.
But the point is when the same code tried on other system works well.

why so
Ken Sampson
Ranch Hand

Joined: Sep 26, 2007
Posts: 45
Hi,

I guess first of all you need to check the correct permissions. Secondly the url might be wrong. You need to specify the port number as well.

It should be like this : jdbc:mysql://localhost:3306/<database_name>

Also in the sqlexplorer are you able to retrieve the records from your sample database which means you need to check if you are able to connect to mysql using sqlexplore in eclipse.

Let me know if there is any issue with this.


Ken Sampson
 
wood burning stoves
 
subject: MySQl with Eclipse3.2
 
Similar Threads
problem with compiling of jsp
BeanUtil populate Error
new to servlet
Error while using Servlets to call EJB i.e CMP
MySQL with Eclipse3.2