*
The moose likes JDBC and the fly likes what is cause of this exception? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "what is cause of this exception?" Watch "what is cause of this exception?" New topic
Author

what is cause of this exception?

Arun Maalik
Ranch Hand

Joined: Oct 25, 2005
Posts: 216
import java.sql.*;


public class today{

public static void main(String\u005B\u005D args){

try{

String st="select * from author;";
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con=DriverManager.getConnection("jdbcdbcSN","sa","");
Statement stmt=con.createStatement();
stmt.executeUpdate("use pubs");

ResultSet rs=stmt.executeQuery(st);


String st1=rs.getString(0);
System.out.print(st1);

}

catch(Exception e){

System.out.println(e);

}

}

}

Hey ranchar in the above code i am getting the exception as
Invalide object name 'Author'. But why all ready there is a table author in pubs. what is the cause of this exception. I think DSN is not connecting with the pubs database.

Regard

Arun
Rama Krishna Ghanta
Ranch Hand

Joined: Nov 20, 2006
Posts: 59
Hi Arun,

Your code chunk seems to be perfect.Check with your table name. It makes a difference between "author" and "Author" if your OS is Red Hat Linux. Also check whether you have the proper jar file in your class path.

Rama Krishna Ghanta


Ram...
Muhammad Saifuddin
Ranch Hand

Joined: Dec 06, 2005
Posts: 1321

Originally posted by Arun Maalik:

String st="select * from author;";
Connection con=DriverManager.getConnection("jdbcdbcSN","sa","");
Statement stmt=con.createStatement();
stmt.executeUpdate("use pubs");

ResultSet rs=stmt.executeQuery(st);

String st1=rs.getString(0);


try this code...



if still problem exist then don't hesitate to ask.
[ December 14, 2006: Message edited by: Saif uddin ]

Saifuddin..
[Blog][Linkedin] How To Ask Questions On JavaRanch My OpenSource
 
wood burning stoves
 
subject: what is cause of this exception?