Solved

jdbc error

Posted on 2002-04-01
21
273 Views
Last Modified: 2013-11-24
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

0
Comment
Question by:Explorer060599
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 14
  • 7
21 Comments
 
LVL 9

Expert Comment

by:Venci75
ID: 6909931
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
 

Author Comment

by:Explorer060599
ID: 6910178
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
 
LVL 9

Expert Comment

by:Venci75
ID: 6910183
Because you don't have ODBC on your linux machine
0
Guide to Performance: Optimization & Monitoring

Nowadays, monitoring is a mixture of tools, systems, and codes—making it a very complex process. And with this complexity, comes variables for failure. Get DZone’s new Guide to Performance to learn how to proactively find these variables and solve them before a disruption occurs.

 

Author Comment

by:Explorer060599
ID: 6910224
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
 
LVL 9

Expert Comment

by:Venci75
ID: 6910230
What server are you using?
0
 

Author Comment

by:Explorer060599
ID: 6910243
redhat 7.2 linux
0
 
LVL 9

Expert Comment

by:Venci75
ID: 6910250
I ment - the web server that executes your servlets
0
 

Author Comment

by:Explorer060599
ID: 6910252
apache 1.3
0
 
LVL 9

Expert Comment

by:Venci75
ID: 6910254
Is there a JServ directory under your Apache directory?
0
 

Author Comment

by:Explorer060599
ID: 6910264
l'm using the tomcat4, do i need to configure the jdbc in tomcat4 ?
0
 

Author Comment

by:Explorer060599
ID: 6910267
if then, how ? i could not found in tomcat4 documentation.
0
 

Author Comment

by:Explorer060599
ID: 6910284
please help, i really do not know how to configure it and find no resource to help.
0
 
LVL 9

Expert Comment

by:Venci75
ID: 6910292
ops - you have tomcat. Then copy the jar file to the tomcat lib directory
0
 

Author Comment

by:Explorer060599
ID: 6910308
tomcat lib....ok..let me try it
0
 

Author Comment

by:Explorer060599
ID: 6910315
what else i need to do ?
0
 
LVL 9

Accepted Solution

by:
Venci75 earned 100 total points
ID: 6910323
may be - to restart your apache server
0
 

Author Comment

by:Explorer060599
ID: 6910331
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
 

Author Comment

by:Explorer060599
ID: 6910332
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
 

Author Comment

by:Explorer060599
ID: 6911689
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
 

Author Comment

by:Explorer060599
ID: 6911774
the error raised "server configuration denies access to data source vendor"
0
 

Author Comment

by:Explorer060599
ID: 6911917
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

Featured Post

Guide to Performance: Optimization & Monitoring

Nowadays, monitoring is a mixture of tools, systems, and codes—making it a very complex process. And with this complexity, comes variables for failure. Get DZone’s new Guide to Performance to learn how to proactively find these variables and solve them before a disruption occurs.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
jmss example java 2 33
Is Applet the way to go for my drag and drop system? 8 35
IBM TS2900 (3572) Tape Autoloader Java? 12 61
How to log java errors in tomcat 8 24
For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question