• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JDBC problem

 
roshan
Greenhorn
Posts: 7
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i used JAVA swings..... which caused me lots of trouble for developing the GUI..

i have even constructed my database.... buth the problem is that i am unable to establish a link between JAVA and database...

i have talked to my lectureres and several other JAVA programmers... they lend me a helping hand.... but i never had been able to find a solution for it.....


i'll post the code here:

import java.sql.*;
import javax.sql.*;



public class DBConnect
{
public static void main(String[] args) throws Exception
{
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");


Connection con=DriverManager.getConnection("jdbcdbc:OracleDriver","scott","tiger");
System.out.println("Connection is created");
}

catch(Exception e)
{
}
/*Statement stmt=con.createStatement();
ResultSet rs=stmt.executeQuery("select * from emp");
while(rs.next())
{
int id=rs.getInt("id");
String name=rs.getString("name");
String city=rs.getString("city");
int salary=rs.getInt("salary");
System.out.println(id +" "+ name + " "+ city+ " " + salary);


}*/
}
}

file name is DBConnect.java

DSN name: OracleDriver

classpath: ./;c:\Program Files\Java\jre1.5.0\lib\rt.jar;C:\Program Files\Java\jdk1.5.0\lib\tools.jar

path: C:\Program Files\Java\jdk1.5.0\bin


no compile time errors

run time error: Exception in thread "main" java.lang.NoClassDefFoundError: DBConnect

i have tried to analyse what the problem is... but i have never hit upon anything... can anyone give me the right solution
 
Ulf Dittmer
Rancher
Pie
Posts: 42966
73
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
classpath: ./; ...

What's that slash doing there?

As an aside, never do this:
catch(Exception e) { }

Ignoring exceptions without even logging them is generally a bad idea, and definitely in this case.
[ June 12, 2008: Message edited by: Ulf Dittmer ]
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic