Subject | Re: [Firebird-Java] ClassNotFoundException |
---|---|
Author | Rick Fincher |
Post date | 2003-12-13T05:58:26Z |
Hi Dave,
The jar file is not in your classpath. You either need to put a -classpath
switch in the command line when you run your Java app or put the jar(s) in
the jre/lib/ext directory of your Java installation directory.
firebirdsql-full.jar has all the routines in it, so it is really the only
jar file you need.
Are you running it inside the IDE or stand alone? If stand alone, you must
have the jars in the classpath one way or another.
Which IDE are you running? You say javabeans, but did you mean Netbeans?
If so it is a little more complicated because the IDE will start its own
copy of the JVM to use with the debugger.
In that case you'll need to install the driver to use internally in the IDE.
For netbeans it is one of the /ext directories inside the install folder. I
forget which, but the IDE docs will tell you.
Usually, though, if it will build in the IDE it will run in the IDE.
Rick
The jar file is not in your classpath. You either need to put a -classpath
switch in the command line when you run your Java app or put the jar(s) in
the jre/lib/ext directory of your Java installation directory.
firebirdsql-full.jar has all the routines in it, so it is really the only
jar file you need.
Are you running it inside the IDE or stand alone? If stand alone, you must
have the jars in the classpath one way or another.
Which IDE are you running? You say javabeans, but did you mean Netbeans?
If so it is a little more complicated because the IDE will start its own
copy of the JVM to use with the debugger.
In that case you'll need to install the driver to use internally in the IDE.
For netbeans it is one of the /ext directories inside the install folder. I
forget which, but the IDE docs will tell you.
Usually, though, if it will build in the IDE it will run in the IDE.
Rick
----- Original Message -----
> Hi!
>
> I'm a newbee to firebird (and to java, that matter) and I'm trying to
> get a simple script to work. It compiles just fine in the javabeans
> IDE, but a runtime error occurs. Here's the script:
>
> import java.sql.*;
>
> public class List_Students {
>
> public static void main(String args[]) {
>
> String query = "select ID, name from student";
>
> try {
> Class.forName("org.firebirdsql.jdbc.FBDriver");
> System.out.println("JDBC Driver loaded");
>
> } catch(java.lang.ClassNotFoundException e) {
> System.err.print("ClassNotFoundException: ");
> System.err.println(e.getMessage());
> }
>
> java.util.Properties properties = new java.util.Properties();
> properties.put ("user", "sysdba");
> properties.put ("password", "masterkey");
>
>
>
> try {
> Connection conn = DriverManager.getConnection
> ("jdbc:firebirdsql://localhost/C:/Firebird/univer.fdb",
> properties);
>
> System.out.println("Connecction established");
>
> Statement stmt = conn.createStatement();
>
>
> ResultSet rs = stmt.executeQuery(query);
> ResultSetMetaData rsmd = rs.getMetaData();
> int numberOfColumns = rsmd.getColumnCount();
> int rowCount = 1;
> while (rs.next()) {
> System.out.println("Row " + rowCount + ": ");
> for (int i = 1; i <= numberOfColumns; i++) {
> System.out.print(" Column " + i + ": ");
> System.out.println(rs.getString(i));
> }
> System.out.println("");
>
> rowCount++;
> }
> stmt.close();
> conn.close();
>
> } catch(SQLException ex) {
> System.err.print("SQLException: ");
> System.err.println(ex.getMessage());
> }
> }
> }
>
>
> ClassNotFoundException: org.firebirdsql.jdbc.FBDriver
> SQLException: No suitable driver
>
> What do I need to do, here, anyone?
>
> Thanks, Dave