jdbc error

hi experts, l'm developing the java servlet in linux rehat 7.2 with mysql installed. when i execute the following code, it returned me with error that i cant see.

Class.forName ("sun.jdbc.odbc.JdbcOdbcDriver");
String url = "jdbc:odbc:test";
Connection con = DriverManager.getConnection ( url, "oboy", "12Java");

where test is database name of mysql, the error raised on the DriverManager.getConnection line. it might properly failed on establised connection. wondering do i need to set up some DSN of mysql database in linux? any idea ? please help..urgent.

thanks

Explorer060599Asked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
Venci75Connect With a Mentor Commented:
may be - to restart your apache server
0
 
Venci75Commented:
use:
Class.forName("org.gjt.mm.mysql.Driver");
String url = "jdbc:mysql://localhost:3306/test";

instead of:
Class.forName ("sun.jdbc.odbc.JdbcOdbcDriver");
String url = "jdbc:odbc:test";
0
 
Explorer060599Author Commented:
its a must to use type 4 driver ? what wrong with my code that used type 1 driver? type 4 is too specified to database vendor, any idea of dynamic loads the database driver?
0
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

 
Venci75Commented:
Because you don't have ODBC on your linux machine
0
 
Explorer060599Author Commented:
i've tried ur code and downloaded and installed the mm.mysql driver. i exported the classpath with the following syntax:

export CLASSPATH=/home/public/mm.mysql/mysql_com.jar

when i tried to run the servlet, it raised the exception at the first line of code. seems it could not find the driver or jar file. l've pointed the CLASSPATH environment variable to that jar file already, why....please help.
0
 
Venci75Commented:
What server are you using?
0
 
Explorer060599Author Commented:
redhat 7.2 linux
0
 
Venci75Commented:
I ment - the web server that executes your servlets
0
 
Explorer060599Author Commented:
apache 1.3
0
 
Venci75Commented:
Is there a JServ directory under your Apache directory?
0
 
Explorer060599Author Commented:
l'm using the tomcat4, do i need to configure the jdbc in tomcat4 ?
0
 
Explorer060599Author Commented:
if then, how ? i could not found in tomcat4 documentation.
0
 
Explorer060599Author Commented:
please help, i really do not know how to configure it and find no resource to help.
0
 
Venci75Commented:
ops - you have tomcat. Then copy the jar file to the tomcat lib directory
0
 
Explorer060599Author Commented:
tomcat lib....ok..let me try it
0
 
Explorer060599Author Commented:
what else i need to do ?
0
 
Explorer060599Author Commented:
ok...let me try later ok...i'm away from my working place. thanks anyway. yeah, do i still need to export that classpath points to that jar file ?
0
 
Explorer060599Author Commented:
ok...let me try later ok...i'm away from my working place. thanks anyway. yeah, do i still need to export that classpath points to that jar file ?
0
 
Explorer060599Author Commented:
hi, l've placed the mysql_comp into lib directory and restart tomcat and apache, but that is still not working. l've found a file tomcat.conf in /etc/tomcat4 that stated the jdbc driver environment setting, but it did not provide with example and how the syntax looks like. please help.
0
 
Explorer060599Author Commented:
the error raised "server configuration denies access to data source vendor"
0
 
Explorer060599Author Commented:
ok, it is working now, i 've found that mysql only listen to localhost, so when i change the address pointing to localhost and it was working fine. i think it would be some setting in mysql to set the address and port to listen at. thanks anywhere.
0
All Courses

From novice to tech pro — start learning today.