db-derby-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nshaw <...@docharley.com>
Subject Problem with Class.forName
Date Sat, 24 Aug 2013 14:55:47 GMT
I've searched just about every site I can find, read the getting started
document and the Apache Derby DB Tutorial by Lars Vogel, I've searched
CLASSPATH, etc. and haven't found an answer.  No matter what I read and try,
I'm having the same problem: when I reach "Class.forName()", I jump to catch
and the program ends. This program is Lars Vogels'.

package tmembers;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.Statement;


public class NewTest {
    private Connection connect = null;
    private Statement statement = null;
    private ResultSet resultSet = null;
    
    public NewTest () throws Exception {
        try {
            //============== here's where I jump to catch ==================
           
Class.forName("org.apache.derby.jdbc.ClientDriver").newInstance(); 

            connect =
DriverManager.getConnection("jdbc:derby://localhost/C:/Users/Doc/Documents/Java
DB/Learning/Users");
            PreparedStatement statement = connect.prepareStatement("SELECT *
from USERS");
            
            resultSet = statement.executeQuery();
            while (resultSet.next()) {
                String user = resultSet.getString("Name");
                String number = resultSet.getString("Number");
                System.out.println("User: " + user);
                System.out.println("ID: " + number);
            }
        } catch (Exception e) {
            throw e;
        } finally {
            close();
        }
    }
    
    private void close() {
        try {
            if (resultSet != null) {
                resultSet.close();
            }
            
            if (statement != null) {
                statement.close();
            }
            
            if (connect != null) {
                connect.close();
            }
        } catch (Exception e) {
            
        }
    }
    
    public static void main (String[] args) throws Exception {
        NewTest dao = new NewTest();
    }    
}  

Here is my JAVA_HOME, PATH, CLASSPATH, and DERBY_HOME (all which display
correctly with ECHO):

JAVA_HOME: C:\Program Files\Java\jdk1.7.0_25

PATH:
%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;%SYSTEMROOT%\System32\WindowsPowerShel
l\v1.0\;C:\Program Files (x86)\Java\jre7\lib\ext\QTJava.zip;C:\Program
Files\Java\jdk1.7.0_25\db\lib;C:\Program
Files\Java\jdk1.7.0_25\bin;C:\Program Files\Java\jre7\bin;%DERBY_HOME%\bin;.

CLASSPATH: .;C:\Program Files (x86)\Java\jre7\lib\ext\QTJava.zip;C:\Program
Files\Java\jdk1.7.0_25\db\lib;C:\Program
Files\Java\jdk1.7.0_25\bin;C:\Program Files\Java\jre7\bin

DERBY_HOME: C:\Program Files\Java\jdk1.7.0_25\db

I pretty much have everything in there except the kitchen sink... I'm using
NetBeans 7.3.1, my JDK is 7.25 and my JRE is 7.  I'm running 64x Windows 7
Professional.

In advance, THANK YOU!

Nick.
 



--
View this message in context: http://apache-database.10148.n7.nabble.com/Problem-with-Class-forName-tp133422.html
Sent from the Apache Derby Users mailing list archive at Nabble.com.

Mime
View raw message