wood burning stoves 2.0*
The moose likes JDBC and the fly likes Class.forName() Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Class.forName()" Watch "Class.forName()" New topic


Arun Maalik
Ranch Hand

Joined: Oct 25, 2005
Posts: 216
import java.sql.*;
public class first{
public static void main(String[] args){
Connection con=DriverManager.getConnection("jdbc.odbc.MyDataSource","sa","");
Statement stmt=con.createStatement();
ResultSet rs=stmt.executeQuery("Select * from authors");
String id=rs.getString("au_id");

catch(Exception e){


Helo frnd In the above code it is throwing a exception that not sutable driver why ?

with regard

marc weber

Joined: Aug 31, 2004
Posts: 11343

Moving to the JDBC forum.

"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer
Naseem Khan
Ranch Hand

Joined: Apr 25, 2005
Posts: 809
Thers is nothing wrong in Class.forName(). Problem is at the time of connection.

At the time of connection, you need to provide three thing.. jdbc_url, username and password.

Your jdbc url is not correct. It should be "jdbcdbc:MyDataSource" instead of "jdbc.odbc.MyDataSource".

[ July 13, 2006: Message edited by: Naseem Khan ]

Asking Smart Questions FAQ - How To Put Your Code In Code Tags
subject: Class.forName()
Similar Threads
how to create summary and detail table
oracle 8i jdbc problem
I can't connect to DB
how to retrive the data of the last row in the table ?
HOW TO Upload files to db (postgres) using java/jdbc