nikolaos
2014-10-05 12:08:43 UTC
I want to use an embedded java db in my application .
Here is what i have done :
Java DB right click -> properties
Java db installation : C:\Program Files\Java\jdk1.8.0_20\db
Database location : C:\Users\...\.netbeans-derby
Services -> Drivers -> right click -> new driver
Driver File : C:\glassfish4\javadb\lib\derby.jar
Driver Class :org.apache.derby.jdbc.EmbeddedDriver
Name :Java DB (Embedded)
Then right click the new driver choose Connect using :
Java DB (Embedded)
Database : suppliers;create=true
username : admin
pwd : admin
JDBC url :jdbc:derby:
Test connection was succesfull
next choose App scema and finish.
the database node appears with jdbc:derby:suppliers;create=true; [admin on APP]
i created a table 'supplier'
put some columns and tried to make a connection from my application
Code:
with the following code
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.logging.Level;
import java.util.logging.Logger;
public class Dbconnection {
{
}
public static void main(String args [])
{
try {
Class.forName("org.apache.derby.jdbc.EmbeddedDriver");
DriverManager.registerDriver(new org.apache.derby.jdbc.EmbeddedDriver());
Connection con= DriverManager.getConnection("jdbc:derby:suppliers;create=true");
PreparedStatement stmt=con.prepareStatement("select * from SUPPLIER");
ResultSet rs=stmt.executeQuery();
} catch (SQLException err) {
System.out.println(err.getMessage()+ "No matching word in database");
} catch (ClassNotFoundException ex) {
Logger.getLogger(Dbconnection.class.getName()).log(Level.SEVERE, null, ex);
}
}
}
result
run:
Table/View 'SUPPLIER' does not exist.No matching word in database
BUILD SUCCESSFUL (total time: 1 second)
i also cannot locate the database anywhere.
Shouldn't it be in C:\Users\...\.netbeans-derby
what do i do wrong?
Here is what i have done :
Java DB right click -> properties
Java db installation : C:\Program Files\Java\jdk1.8.0_20\db
Database location : C:\Users\...\.netbeans-derby
Services -> Drivers -> right click -> new driver
Driver File : C:\glassfish4\javadb\lib\derby.jar
Driver Class :org.apache.derby.jdbc.EmbeddedDriver
Name :Java DB (Embedded)
Then right click the new driver choose Connect using :
Java DB (Embedded)
Database : suppliers;create=true
username : admin
pwd : admin
JDBC url :jdbc:derby:
Test connection was succesfull
next choose App scema and finish.
the database node appears with jdbc:derby:suppliers;create=true; [admin on APP]
i created a table 'supplier'
put some columns and tried to make a connection from my application
Code:
with the following code
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.logging.Level;
import java.util.logging.Logger;
public class Dbconnection {
{
}
public static void main(String args [])
{
try {
Class.forName("org.apache.derby.jdbc.EmbeddedDriver");
DriverManager.registerDriver(new org.apache.derby.jdbc.EmbeddedDriver());
Connection con= DriverManager.getConnection("jdbc:derby:suppliers;create=true");
PreparedStatement stmt=con.prepareStatement("select * from SUPPLIER");
ResultSet rs=stmt.executeQuery();
} catch (SQLException err) {
System.out.println(err.getMessage()+ "No matching word in database");
} catch (ClassNotFoundException ex) {
Logger.getLogger(Dbconnection.class.getName()).log(Level.SEVERE, null, ex);
}
}
}
result
run:
Table/View 'SUPPLIER' does not exist.No matching word in database
BUILD SUCCESSFUL (total time: 1 second)
i also cannot locate the database anywhere.
Shouldn't it be in C:\Users\...\.netbeans-derby
what do i do wrong?