I need help for Java/JDBC. I hava created a database. I have set the
odbc driver (viz. addr_book). Then I wrote the following java
program. Tried to compile it. It gave the error :
C:\ABC\Java\JDBC>java MakingAStatement.java
Exception in thread "main" java.lang.NoClassDefFoundError:
MakingAStatement/java
---------------------------------------------------
import java.lang.*;
import java.sql.*;
public class MakingAStatement
{
public static void main (string[] args)
{
// Load the driver
try
{
// Load the driver class
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
// This defines the data source for the driver
String sourceURL = new String("jdbc:odbc:addr_book");
// Create connection through the DriverManager
Connection databaseConnection = DriverManager.getConnection
(sourceURL);
Statement statement = databaseConnection.createStatement();
ResultSet authorNames = statement.executeQuery("SELECT lname,
fname FROM Address_Book");
// Output the resultset data
while(authorNames.next())
System.out.println(authorNames.getString("lname") + ", " +
authorNames.getString("fname"));
}
catch(ClassNotFoundException cnfe)
{
System.err.println(cnfe);
}
catch(SQLException sqle)
{
System.err.println(sqle);
}
}
}