Re: [SLUG] Java help

From: Kwan Lowe (kwan@digitalhermit.com)
Date: Sat Dec 20 2003 - 21:11:50 EST


> Hey Sluggers
> 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 conectj
> driver installed.

Sounds like some sort of security policy error. Try editing the security
policy and granting all permission *to test only*. If allowing all gives you
access then that will confirm a policy problem.

>
> MY CODE:
> try
> {
> //using MySQL database connectj driver
> //www.mysql.com
> //syntax eample:
> //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.java:1797)
> at com.mysql.jdbc.Connection.<init>(Connection.java:562)
> at
> com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:361)
> at java.sql.DriverManager.getConnection(DriverManager.java:512)
> at java.sql.DriverManager.getConnection(DriverManager.java:193)
> at finalProject.AddressBook.myInit(AddressBook.java:398)
> at finalProject.AddressBook.init(AddressBook.java:85)
> at sun.applet.AppletPanel.run(AppletPanel.java:353)
> at java.lang.Thread.run(Thread.java:534)
>
>
>
> -----------------------------------------------------------------------
> This list is provided as an unmoderated internet service by Networked
> Knowledge Systems (NKS). Views and opinions expressed in messages
> posted are those of the author and do not necessarily reflect the
> official policy or position of NKS or any of its employees.
>

-- 
* The Digital Hermit   http://www.digitalhermit.com
* Unix and Linux Solutions   kwan@digitalhermit.com
-----------------------------------------------------------------------
This list is provided as an unmoderated internet service by Networked
Knowledge Systems (NKS).  Views and opinions expressed in messages
posted are those of the author and do not necessarily reflect the
official policy or position of NKS or any of its employees.



This archive was generated by hypermail 2.1.3 : Fri Aug 01 2014 - 19:49:30 EDT