You are viewing a plain text version of this content. The canonical link for it is here.
Posted to derby-user@db.apache.org by "Kaoullas, Adamos D" <a....@imperial.ac.uk> on 2005/02/09 19:20:54 UTC

Obtaining JDBC connection using Derby embedded driver takes a long time...

Greetings all,
 
I am using Derby as an embedded database for an application I am
developing. I am obtaining a JDBC connection using the DriverManager
class. I am then using this connection to execute a series of SQL
statements and thereby create my database tables. It seems to take a
very long time to do this. It takes approximately 8 seconds to obtain
the connection, and  a further 8 seconds to execute about 10 CREATE
table statements. Is this normal? I am using version 10.0.2.1 on Windows
XP. I have a attached a test program I wrote to show how I am starting
the database:
 
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

public class TestDerbyDB {
	public static void main(String[] args) {
		System.out.println("loading jdbc driver");
		try {
	
Class.forName("org.apache.derby.jdbc.EmbeddedDriver");
			System.out.println("JDBC driver loaded
succesfully");
			System.out.println("creating database");
			Connection conn = DriverManager
	
.getConnection("jdbc:derby:c:/temp/Wombat2DB;create=true");
			System.out.println("database created");
		} catch (SQLException ex1) {
			ex1.printStackTrace();
		} catch (ClassNotFoundException ex) {
			ex.printStackTrace();
		}
	}
}

Kind regards,

Adam Kaoullas

Re: Obtaining JDBC connection using Derby embedded driver takes a long time...

Posted by Suavi Ali Demir <de...@yahoo.com>.
Yes it is normal. Imagine you are starting a whole
database engine with that first connection and on top
of that you are creating a brand new database when it
is the first time:

System.out.println("creating database");
Connection conn =
DriverManager.getConnection("jdbc:derby:c:/temp/Wombat2DB;create=true");

Try "create database" command with any database server
and it will take time. Bringing up any database server
takes time too.

After your database is created, if you pool your
connections and cache prepared statements everything
is fast with Derby.

Regards,
Ali


--- "Kaoullas, Adamos D" <a....@imperial.ac.uk>
wrote:

> Greetings all,
>  
> I am using Derby as an embedded database for an
> application I am
> developing. I am obtaining a JDBC connection using
> the DriverManager
> class. I am then using this connection to execute a
> series of SQL
> statements and thereby create my database tables. It
> seems to take a
> very long time to do this. It takes approximately 8
> seconds to obtain
> the connection, and  a further 8 seconds to execute
> about 10 CREATE
> table statements. Is this normal? I am using version
> 10.0.2.1 on Windows
> XP. I have a attached a test program I wrote to show
> how I am starting
> the database:
>  
> import java.sql.Connection;
> import java.sql.DriverManager;
> import java.sql.SQLException;
> 
> public class TestDerbyDB {
> 	public static void main(String[] args) {
> 		System.out.println("loading jdbc driver");
> 		try {
> 	
>
Class.forName("org.apache.derby.jdbc.EmbeddedDriver");
> 			System.out.println("JDBC driver loaded
> succesfully");
> 			System.out.println("creating database");
> 			Connection conn = DriverManager
> 	
>
.getConnection("jdbc:derby:c:/temp/Wombat2DB;create=true");
> 			System.out.println("database created");
> 		} catch (SQLException ex1) {
> 			ex1.printStackTrace();
> 		} catch (ClassNotFoundException ex) {
> 			ex.printStackTrace();
> 		}
> 	}
> }
> 
> Kind regards,
> 
> Adam Kaoullas
>