Two Laptop Bag*
The moose likes JDBC and the fly likes JDBC problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Databases » JDBC
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: 41155
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 ]

Ping & DNS - my free Android networking tools app
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
Similar Threads
SQL Server 2000 Database Connection using JDBC
jdbc program written in Eclipse3.2.1 to connect DB2
jdbc programm connecting DB2, error thrown in cmd as "null user id is not supported"
difference between different web technologies
jdbc with as400