File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JDBC and Relational Databases and the fly likes JDBC problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "JDBC problem" Watch "JDBC problem" New topic

JDBC problem


Joined: Jun 11, 2008
Posts: 7
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

Joined: Mar 22, 2005
Posts: 42959
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

Joined: Dec 11, 2004
Posts: 13410

Please check your private messages.

Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
I agree. Here's the link:
subject: JDBC problem
It's not a secret anymore!