开发者

Java applet connects to mysql in IDE but fails to connect in web browser

I am trying hard to build an applet which takes input text from MYSQL database and displays on the screen. I get the connection to MySQL in when I run it netbeans but it fails when I run the same in browser with the error

Communications link failure Last packet sent to the server was 0 ms ago.

Believe me I went through all the posts related to mine on this forum. But none of them was useful to me. I also tried *signing * the JAR. But still it's not working.

Below is the code of the class which I want to execute from My JAR archive.

String url = "jdbc:mysql://127.0.0.1/MYdb";
Connection con = DriverManager.getConnection(url,"root", "pass");

I went through all possible solutions on net.开发者_运维问答 And finally I am posting over here. Please help me in this. If it's not possible the is there any other way to fetch data from database in an applet?? I am waiting for your valuable reply. Thank you.


When run from Netbeans, the applet runs from the /test directory or /build directory, from the application folder. Usually the drivers will be in /lib so no problem here.

When run from browser, the applet will be running from it's own jar file, so you will need to make that all the libraries (JDBC drivers) required are on your classpath.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜