Sorry for this (maybe) stupid question. I need to create some local DB in my java project so I've decided for Apache Derby Client. I am working with IntelliJ IDEA 13 Ultimate and my problem is that I don't know, how to create local database. Tutorials at Jetbrains websites aren't useful because there are articles only about connecting to the remote DB, not to the local one (or at least I didn't find them yet).
What have I done so far:
- I've tried to set the DB up by creating new remote derby data source. Screenshot with the settings: DB Settings screen
Username and password are the same: admin
- After clicking
test connection, this error is thrown: error - When I click
applyandok, it says that it's connected, but exception is still there.
So do you have any idea where the problem can be? I've got small confiuration class called DatabaseSetting.java
package issuetrackinglite;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
public class DatabaseSetting {
private String dbURL = "jdbc:derby://localhost:1527/MallDB;create=true";
private String user = "admin";
private String password = "admin";
private Connection connection;
public static final String CREATE_ITEMS_DB = "CREATE TABLE items (item_id INTEGER NOT NULL, item_name VARCHAR(20) NOT NULL, item_price REAL NOT NULL, multiplicity_shop INTEGER NOT NULL, multiplicity_store INTEGER NOT NULL)";
public static final String INSERT_PRODUCT = "INSERT INTO items (item_id, item_name, item_price, multiplicity_shop, multiplicity_store) VALUES (?, ?, ?, ?, ?)";
public static final String CLEAR_ITEMS_DB = "DELETE FROM items";
// -------------------------------------------------------------
protected Connection connectToDB() {
try {
connection = DriverManager.getConnection(dbURL, user, password);
return connection;
} catch (SQLException ex) {
System.out.println("SQL exception - connectToDB(): " + ex.getMessage());
return null;
}
}
}
EDIT
Simply explained: I just need to create virtual derby database which will be created every time at the program start.
I don't know, how to do it in IntelliJ.
I've added DERBY_HOME to the enviroment variables and also added path to Derby. Now this error is thrown by IntelliJ: Error window
Thank you very much for your help and time