Ok so I have a database in netbeans following this tutorial
Working with the Java DB (Derby) Database - NetBeans IDE 6.8 Tutorial
and this worked great I got the dtabase up and running and its connected and has 2 rows in the book talbe and two rows in the patron table. I can view the data by right clicking the table and selecting view data and that works so the data is in the talbe and the little connection sysble shows that it is connected. The problem is when I try to connect to the database with the java app that does not work. It says no suitable drive found
java.sql.SQLException: No suitable driver found for jdbc:derby://localhost:1527/BOOK;jdbc.username=Gus
Here is the java app:
Thanks for any help on thisimport java.sql.*; import java.io.*; import java.util.*; class TestDB { public static void main(String args[]) { try { runTest(); } catch (SQLException ex) { for (Throwable t : ex) t.printStackTrace(); } catch (IOException ex) { ex.printStackTrace(); } } /** * Runs a test by creating a table, adding a value, showing the table contents, and removing the * table. */ public static void runTest() throws SQLException, IOException { Connection conn = getConnection(); try { Statement stat = conn.createStatement(); stat.executeUpdate("CREATE TABLE Greetings (Message CHAR(20))"); stat.executeUpdate("INSERT INTO Greetings VALUES ('Hello, World!')"); ResultSet result = stat.executeQuery("SELECT * FROM Greetings"); if (result.next()) System.out.println(result.getString(1)); result.close(); stat.executeUpdate("DROP TABLE Greetings"); } finally { conn.close(); } } /** * Gets a connection from the properties specified in the file database.properties * @return the database connection */ public static Connection getConnection() throws SQLException, IOException { Properties props = new Properties(); FileInputStream in = new FileInputStream("database.properties"); props.load(in); in.close(); String drivers = props.getProperty("jdbc.drivers"); if (drivers != null) System.setProperty("jdbc.drivers", drivers); String url = props.getProperty("jdbc.url"); String username = props.getProperty("jdbc.username"); String password = props.getProperty("jdbc.password"); return DriverManager.getConnection(url, username, password); } }