dany996
asked on
java webstart + mysql
Hi,
i've write a little class to connect to mysql server:
Connection conn = null;
try {
String userName = "root";
String password = "admin";
String url = "jdbc:mysql://hostname:330 6/cs";
try {
Class.forName("com.mysql.j dbc.Driver ").newInst ance();
} catch (Exception e) {
System.err.println(e.toStr ing());
}
try {
conn = DriverManager.getConnectio n(url, userName, password);
System.out.println("Databa se connection established");
} catch (Exception e) {
System.err.println(e.getSt ackTrace() );
}
} catch (Exception e) {
System.err.println(e.toStr ing());
}
If the class is executed in a Java application, it's ok, but when using Java Webstart i get error shown below:
Communications link failure due to underlying exception:
** BEGIN NESTED EXCEPTION
java.net.SocketException
MESSAGE: java.security.AccessContro lException : access denied (java.net.SocketPermission hostname:3306 connect,resolve)
STACKTRACE:
java.net.SocketException: java.security.AccessContro lException : access denied (java.net.SocketPermission hostname:3306 connect,resolve)tat com.mysql.jdbc.StandardSoc ketFactory .connect(S tandardSoc ketFactory .java:156)
com.mysql.jdbc.MysqlIO.<in it>(MysqlI O.java:276 )
com.mysql.jdbc.Connection. createNewI O(Connecti on.java:26 41)
com.mysql.jdbc.Connection. <init>(Con nection.ja va:1531)
com.mysql.jdbc.NonRegister ingDriver. connect(No nRegisteri ngDriver.j ava:266)
java.sql.DriverManager.get Connection (DriverMan ager.java: 525)
java.sql.DriverManager.get Connection (DriverMan ager.java: 171)
Cs.getNewConnection(Cs.jav a:218)
Cs.start(Cs.java:452)
Cs.<init>(Cs.java:1234)
Cs$21.run(Cs.java:1709)
java.awt.event.InvocationE vent.dispa tch(Invoca tionEvent. java:209)
java.awt.EventQueue.dispat chEvent(Ev entQueue.j ava:461)
java.awt.EventDispatchThre ad.pumpOne EventForHi erarchy(Ev entDispatc hThread.ja va:242)
java.awt.EventDispatchThre ad.pumpEve ntsForHier archy(Even tDispatchT hread.java :163)
java.awt.EventDispatchThre ad.pumpEve nts(EventD ispatchThr ead.java:1 57)
java.awt.EventDispatchThre ad.pumpEve nts(EventD ispatchThr ead.java:1 49)
java.awt.EventDispatchThre ad.run(Eve ntDispatch Thread.jav a:110)
** END NESTED EXCEPTION **
packet sent to the server was 371 ms ago.
i test this class in NetBeans 5.0 ide environment, and the database is located in a remote server.
i try to add <security> <all-permissions/> </security> tag to my jnlp file bat an error message tell me that the jar is not signed (obviously,i did that)
..thank you
i've write a little class to connect to mysql server:
Connection conn = null;
try {
String userName = "root";
String password = "admin";
String url = "jdbc:mysql://hostname:330
try {
Class.forName("com.mysql.j
} catch (Exception e) {
System.err.println(e.toStr
}
try {
conn = DriverManager.getConnectio
System.out.println("Databa
} catch (Exception e) {
System.err.println(e.getSt
}
} catch (Exception e) {
System.err.println(e.toStr
}
If the class is executed in a Java application, it's ok, but when using Java Webstart i get error shown below:
Communications link failure due to underlying exception:
** BEGIN NESTED EXCEPTION
java.net.SocketException
MESSAGE: java.security.AccessContro
STACKTRACE:
java.net.SocketException: java.security.AccessContro
com.mysql.jdbc.MysqlIO.<in
com.mysql.jdbc.Connection.
com.mysql.jdbc.Connection.
com.mysql.jdbc.NonRegister
java.sql.DriverManager.get
java.sql.DriverManager.get
Cs.getNewConnection(Cs.jav
Cs.start(Cs.java:452)
Cs.<init>(Cs.java:1234)
Cs$21.run(Cs.java:1709)
java.awt.event.InvocationE
java.awt.EventQueue.dispat
java.awt.EventDispatchThre
java.awt.EventDispatchThre
java.awt.EventDispatchThre
java.awt.EventDispatchThre
java.awt.EventDispatchThre
** END NESTED EXCEPTION **
packet sent to the server was 371 ms ago.
i test this class in NetBeans 5.0 ide environment, and the database is located in a remote server.
i try to add <security> <all-permissions/> </security> tag to my jnlp file bat an error message tell me that the jar is not signed (obviously,i did that)
..thank you
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
yes u need to include the mysql jar in your jnlp, and u also need to sign that jar
if its saying it isn't then check it isn't being cached, and its using an unsigned version
if its saying it isn't then check it isn't being cached, and its using an unsigned version
ASKER
i solved the problem, for unknown reason the java web start said the mysql-connector-java-5.0.3 -bin.jar was unsigned
but the jarsign -verify confirmed me that jar was correctly signed!
so, i unziped the jar then i removed the manifest file, zip again and then sign again.
after this all works fine.
someone can explain me why?
but the jarsign -verify confirmed me that jar was correctly signed!
so, i unziped the jar then i removed the manifest file, zip again and then sign again.
after this all works fine.
someone can explain me why?
was it signed with the same cert that you app was signed with?
ASKER
..yes.
ASKER
sorry, i'd like to share points to Ajay-Singh and objects,
how can i do?
how can i do?
ASKER
i try to debug the class in the NetBeans 5.0 ide environment the problems are:
(i should sign the jar also in debug mode?, if so, how can do it?)
in debug i get this exception "java.lang.ClassNotFoundEx
to execute Class.forName("com.mysql.j
so i've insert into the jnlp resources entry:
<resources locale="" os="">
<jar download="eager" href="dist/mysql-connector
</resources>
in this case the drive is loaded but when the statement below is executed i get the
java.security.AccessContro
conn = DriverManager.getConnectio
so i try to deploy the application and then sing then jar and the mysql-connector-java-5.0.3
put the war file on the tomcat server, stop the service replace the jar with the signed one
then restart.
in this case i get the error
An error has been taken place during the execution of the application.
Title: test
Fornitore: Company, Inc.
category: download error
resource not signed: http://hostname:8080/prova/dist/mysql-connector-java-5.0.3-bin.jar
..but the jar is singed!
this is the jnlp generated by netbeans:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE jnlp PUBLIC "-//Sun Microsystems, Inc.//DTD JNLP 1.5//EN" "http://www.netbeans.org/jnlp/DTD/jnlp.dtd">
<jnlp codebase="$$codebase" href="prova.jnlp">
<information>
<title>test</title>
<vendor>Company, Inc.</vendor>
<homepage href="homepage.html"/>
<description> </description>
<icon href="default"/>
<offline-allowed/>
<shortcut online="true"/>
</information>
<resources>
<j2se href="http://java.sun.com/products/autodl/j2se" version="1.4+"/>
</resources>
<resources>
<jar download="eager" href="dist/prova.jar" main="false"/>
</resources>
<resources locale="" os="">
<jar download="eager" href="dist/mysql-connector
</resources>
<application-desc main-class="prova.Main"/>
</jnlp>
thanks