If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > MySQL > Java mysql connect error

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 12-20-03, 19:24
CaptainEstock CaptainEstock is offline
Registered User
 
Join Date: Jun 2002
Posts: 16
Java mysql connect error

Hello all
I'm having some problems with a java app I'm writing for school. I have mysql running on my local box and the database and table exist. The user has insert update select delete rights. I have the mysql connector/j driver installed.

Thanks in advance
The Captain

MY CODE:
try
{
//using MySQL database connectj driver
//www.mysql.com
//syntax example:
//String cs = "jdbc:mysql://"+dbserver+"/"+dbname+"?user="+user
+"&password="+password;
url = "jdbc:mysql://127.0.0.1:3306/TS5502?user=java&password=secret";
//register the MySQL Driver
Class.forName("com.mysql.jdbc.Driver").newInstance ();
connect = DriverManager.getConnection(url);
connectField.setText("Connection successful");

}
catch(ClassNotFoundException cnfx)
{
cnfx.printStackTrace();
connectField.setText("Connection unsuccessful" + cnfx.toString());
}
catch (SQLException sqlx)
{
sqlx.printStackTrace();
connectField.setText("Connection unsuccessful" + sqlx.toString());
}
catch (Exception ex)
{
ex.printStackTrace();
connectField.setText("Connection unsuccessful" + ex.toString());
}


THE ERROR:

java.sql.SQLException: Unable to connect to any hosts due to exception:
java.security.AccessControlException: access denied
(java.net.SocketPermission 127.0.0.1:3306 connect,resolve)
at com.mysql.jdbc.Connection.createNewIO(Connection.j ava:1797)
at com.mysql.jdbc.Connection.<init>(Connection.java:5 62)
at
com.mysql.jdbc.NonRegisteringDriver.connect(NonReg isteringDriver.java:361)
at java.sql.DriverManager.getConnection(DriverManager .java:512)
at java.sql.DriverManager.getConnection(DriverManager .java:193)
at finalProject.AddressBook.myInit(AddressBook.java:3 98)
at finalProject.AddressBook.init(AddressBook.java:85)
at sun.applet.AppletPanel****n(AppletPanel.java:353)
at java.lang.Thread****n(Thread.java:534)
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On