Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

mysql sriver is not conncting from java web server

Status
Not open for further replies.

daka94

Programmer
Apr 27, 2001
33
US
hai,
i am trying to connect from applet to mysql database.for that i am using mm.mysql.jdbc-1.2c driver .i put the driver's jar file mysql_jar in public_html file.
my class file is also there in public_html.i set the archive parameter in html file.
this entire thing works on local mechine i.e means when i put in local directory(c drive)and access from browser.but it is not working when i put on java webserver.
please help me.
code is given below.
public void connectDBase()
{
String sHost = getCodeBase().getHost();
try{
Class.forName("org.gjt.mm.mysql.Driver").newInstance();
}
catch(Exception e)
{
System.out.println(e.toString());
}
try{
con = DriverManager.getConnection("jdbc:mysql://"+sHost+"/dbname");
}catch(Exception e){
System.out.println(e.toString());
}
}
and html file is
<HTML>
<HEAD>
<TITLE> New Document </TITLE>
<META NAME=&quot;Generator&quot; CONTENT=&quot;EditPlus&quot;>
<META NAME=&quot;Author&quot; CONTENT=&quot;&quot;>
<META NAME=&quot;Keywords&quot; CONTENT=&quot;&quot;>
<META NAME=&quot;Description&quot; CONTENT=&quot;&quot;>
</HEAD>

<BODY>

<!--&quot;CONVERTED_APPLET&quot;-->
<!-- CONVERTER VERSION 1.3 -->
<OBJECT classid=&quot;clsid:8AD9C840-044E-11D1-B3E9-00805F499D93&quot;
WIDTH = &quot;300&quot; HEIGHT = &quot;100&quot; NAME = &quot;timer&quot; codebase=&quot;<PARAM NAME = CODE VALUE = &quot;p1.TimerApplet&quot; >
<PARAM NAME = ARCHIVE VALUE = &quot;mysql_comp.jar&quot; >
<PARAM NAME = NAME VALUE = &quot;timer&quot; >

<PARAM NAME=&quot;type&quot; VALUE=&quot;application/x-java-applet;version=1.3&quot;>
<PARAM NAME=&quot;scriptable&quot; VALUE=&quot;false&quot;>
<PARAM NAME = username VALUE =player_name>
<COMMENT>
<EMBED type=&quot;application/x-java-applet;version=1.3&quot; CODE = &quot;p1.TimerApplet&quot; ARCHIVE = &quot;mysql_comp.jar&quot; NAME = &quot;timer&quot; WIDTH = &quot;300&quot; HEIGHT = &quot;100&quot; username = player_name scriptable=false pluginspage=&quot;
</NOEMBED></EMBED>
</OBJECT>

<!--
<APPLET CODE = &quot;p1.TimerApplet&quot; ARCHIVE = &quot;mysql_comp.jar&quot; WIDTH = &quot;300&quot; HEIGHT = &quot;100&quot; NAME = &quot;timer&quot;>
<PARAM NAME = username VALUE =player_name>


</APPLET>
-->
<!--&quot;END_CONVERTED_APPLET&quot;-->


</BODY>
</HTML>
thank you
 
Hi,

Applets can't connect to database. Use servlets as an intermediate instead. Meaning get your applet to connect to the servlet, the servlet read from database and return something to your applet.

Regards,
Leon If you need additional help, you can email to me at zaoliang@hotmail.com I don't guaranty that I will be able to solve your problems but I will try my best :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top