I'm a new comer to Derby and also to databases generally for your matter. How do i produce a prepared statment to have an embedded derby database? I am not sure since the database is embedded.

My String is:

final String updateString = "create table " + TABLE_NAME_TBL_IPS + " (" +
                TABLE_COLUMN_IP + " " + TABLE_COLUMN_IP_DATA_TYPE + ")";

Also what's the advantage of by using this like a saved procedure rather than a prepared statement call?

It does not really matter when the database is embedded or otherwise, as lengthy because it has JDBC connectivity. Inside your situation, Derby provides you to definitely the connection information.

Your code may look something similar to this:-

// much easier to read with String.format()... in my opinion
final String updateString = String.format("create table %s (%s %s, %s %s)",

Connection con = null;

try {
    con = DriverManager.getConnection("jdbc:derby:yourDatabaseName");

    PreparedStatement ps = con.prepareStatement(updateString);
catch (SQLException e) {
finally {
    try {
    catch (Exception ignored) {

Relating to your wonder if to do this utilizing a saved procedure or perhaps a PreparedStatement, you will find couple of information available you're easily search. You generally make use of a saved procedure to group couple of SQL claims whereas a PreparedStatement only enables you to definitely execute one SQL statement. It may be beneficial to make use of saved methods if you plan to reveal that API to permit your customers to complete it no matter technology (Java, .Internet, PHP). However, if you're penning this SQL statement just for your Java application to operate, then it seems sensible to simply use PreparedStatement.

Because you note that you're a new comer to both Derby and also to databases generally, here is a couple good assets: http://download.oracle.com/javase/tutorial/jdbc/index.html and http://db.apache.org/derby/papers/DerbyTut/