aspose file tools*
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
JavaRanch » Java Forums » Databases » JDBC
Bookmark "JDBC problem" Watch "JDBC problem" New topic
Author

JDBC problem

roshan
Greenhorn

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
{
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
Marshal

Joined: Mar 22, 2005
Posts: 42635
    
  65
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
Sheriff

Joined: Dec 11, 2004
Posts: 13410

"roshan",
Please check your private messages.
-Ben


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JDBC problem