Win a copy of Android Programming: The Big Nerd Ranch Guide this week in the Android forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

JDBC problem  RSS feed

Posts: 7
  • 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

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");
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

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
Posts: 42972
  • 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
Posts: 13411
Firefox Browser Redhat VI Editor
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!