derby-user Digest 9 Feb 2007 18:46:30 -0000 Issue 466
Topics (messages 6126 through 6130):
Re: connection to derby failed
6126 by: Pranav Aggarwal
6127 by: Rajesh Kartha
6128 by: Thomas J. Taylor
Problem with create table in Derby 10.2.2.0
6129 by: Leo Alberto
6130 by: Mamta Satoor
Administrivia:
---------------------------------------------------------------------
To post to the list, e-mail: [email protected]
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
----------------------------------------------------------------------
------------------------------------------------------------------------
Subject:
ref: connection to derby failed
From:
Pranav Aggarwal <[EMAIL PROTECTED]>
Date:
Fri, 09 Feb 2007 09:06:20 +0530
To:
Derby Discussion <[email protected]>
To:
Derby Discussion <[email protected]>
Hi all,
I am new to Derby, just trying a small program which makes connection
to derby DB.
Following program I have written:
import java.sql.*;
class derby_connect
{
void connect() throws Exception
{
String driver="org.apache.derby.jdbc.EmbeddedDriver";
String dbName="mydb";
String connectionURL="jdbc:derby:"+dbName;
Connection conn=null;
try
{
Class.forName(driver);
}catch(java.lang.ClassNotFoundException e)
{
e.printStackTrace();
}
try
{
conn=DriverManager.getConnection(connectionURL);
System.out.println("Connection established!!!");
}
catch(Throwable e)
{e.printStackTrace();}
finally {conn.close();}
}//end of connect()
public static void main(String args[]) throws Exception
{
derby_connect dc=new derby_connect();
dc.connect();
}
}//end of class
The program resides in same directory where DB is residing. Now when I
run, I get the following error:
$ java derby_connect
java.sql.SQLException: Failed to start database 'mydb', see the next
exception for details.
at
org.apache.derby.impl.jdbc.SQLExceptionFactory40.getSQLException(Unknown
Source)
at org.apache.derby.impl.jdbc.Util.newEmbedSQLException(Unknown
Source)
at org.apache.derby.impl.jdbc.Util.newEmbedSQLException(Unknown
Source)
at
org.apache.derby.impl.jdbc.Util.generateCsSQLException(Unknown Source)
at
org.apache.derby.impl.jdbc.EmbedConnection.newSQLException(Unknown
Source)
at
org.apache.derby.impl.jdbc.EmbedConnection.bootDatabase(Unknown Source)
at org.apache.derby.impl.jdbc.EmbedConnection.<init>(Unknown
Source)
at org.apache.derby.impl.jdbc.EmbedConnection30.<init>(Unknown
Source)
at org.apache.derby.impl.jdbc.EmbedConnection40.<init>(Unknown
Source)
at org.apache.derby.jdbc.Driver40.getNewEmbedConnection(Unknown
Source)
at org.apache.derby.jdbc.InternalDriver.connect(Unknown Source)
at org.apache.derby.jdbc.AutoloadedDriver.connect(Unknown Source)
at java.sql.DriverManager.getConnection(DriverManager.java:582)
at java.sql.DriverManager.getConnection(DriverManager.java:207)
at derby_connect.connect(derby_connect.java:21)
at derby_connect.main(derby_connect.java:32)
Caused by: java.sql.SQLException: Failed to start database 'mydb', see
the next exception for details.
at
org.apache.derby.impl.jdbc.SQLExceptionFactory.getSQLException(Unknown
Source)
at
org.apache.derby.impl.jdbc.SQLExceptionFactory40.wrapArgsForTransportAcrossDRDA(Unknown
Source)
... 16 more
Exception in thread "main" java.lang.NullPointerException
at derby_connect.connect(derby_connect.java:26)
at derby_connect.main(derby_connect.java:32)
Can any one help me with this?
------------------------------------------------------------------------
Subject:
Re: ref: connection to derby failed
From:
Rajesh Kartha <[EMAIL PROTECTED]>
Date:
Thu, 08 Feb 2007 20:25:00 -0800
To:
Derby Discussion <[email protected]>
To:
Derby Discussion <[email protected]>
Hi Pranav,
In the embedded mode, a Derby database can be booted only by a single
JVM (use the
Network server if you want multiple applications to access the db).
Looking at the
error you mentioned the first thing is to *ensure *no other
application (tools like 'ij') is using
(connected to) the 'mydb' while you are running you little test program.
The test program in your mail is very straight forward and I don't see
why the connect should not work
if the 'mydb' is present and is currently not being used by other
applications.
-Rajesh
Pranav Aggarwal wrote:
Hi all,
I am new to Derby, just trying a small program which makes connection
to derby DB.
Following program I have written:
import java.sql.*;
class derby_connect
{
void connect() throws Exception
{
String driver="org.apache.derby.jdbc.EmbeddedDriver";
String dbName="mydb";
String connectionURL="jdbc:derby:"+dbName;
Connection conn=null;
try
{
Class.forName(driver);
}catch(java.lang.ClassNotFoundException e)
{
e.printStackTrace();
}
try
{
conn=DriverManager.getConnection(connectionURL);
System.out.println("Connection established!!!");
}
catch(Throwable e)
{e.printStackTrace();}
finally {conn.close();}
}//end of connect()
public static void main(String args[]) throws Exception
{
derby_connect dc=new derby_connect();
dc.connect();
}
}//end of class
The program resides in same directory where DB is residing. Now when
I run, I get the following error:
$ java derby_connect
java.sql.SQLException: Failed to start database 'mydb', see the next
exception for details.
at
org.apache.derby.impl.jdbc.SQLExceptionFactory40.getSQLException(Unknown
Source)
at org.apache.derby.impl.jdbc.Util.newEmbedSQLException(Unknown
Source)
at org.apache.derby.impl.jdbc.Util.newEmbedSQLException(Unknown
Source)
at
org.apache.derby.impl.jdbc.Util.generateCsSQLException(Unknown Source)
at
org.apache.derby.impl.jdbc.EmbedConnection.newSQLException(Unknown
Source)
at
org.apache.derby.impl.jdbc.EmbedConnection.bootDatabase(Unknown Source)
at org.apache.derby.impl.jdbc.EmbedConnection.<init>(Unknown
Source)
at org.apache.derby.impl.jdbc.EmbedConnection30.<init>(Unknown
Source)
at org.apache.derby.impl.jdbc.EmbedConnection40.<init>(Unknown
Source)
at org.apache.derby.jdbc.Driver40.getNewEmbedConnection(Unknown
Source)
at org.apache.derby.jdbc.InternalDriver.connect(Unknown Source)
at org.apache.derby.jdbc.AutoloadedDriver.connect(Unknown Source)
at java.sql.DriverManager.getConnection(DriverManager.java:582)
at java.sql.DriverManager.getConnection(DriverManager.java:207)
at derby_connect.connect(derby_connect.java:21)
at derby_connect.main(derby_connect.java:32)
Caused by: java.sql.SQLException: Failed to start database 'mydb',
see the next exception for details.
at
org.apache.derby.impl.jdbc.SQLExceptionFactory.getSQLException(Unknown
Source)
at
org.apache.derby.impl.jdbc.SQLExceptionFactory40.wrapArgsForTransportAcrossDRDA(Unknown
Source)
... 16 more
Exception in thread "main" java.lang.NullPointerException
at derby_connect.connect(derby_connect.java:26)
at derby_connect.main(derby_connect.java:32)
Can any one help me with this?
------------------------------------------------------------------------
Subject:
Re: ref: connection to derby failed
From:
"Thomas J. Taylor" <[EMAIL PROTECTED]>
Date:
Fri, 09 Feb 2007 01:55:50 -0500
To:
Derby Discussion <[email protected]>
To:
Derby Discussion <[email protected]>
Hi Pranav,
If the database doesn't already exist, don't forget to include the
'create=true' property.
For example,
**jdbc:derby:sampleDB;create=true**
Further explained in the Derby documentation:
http://db.apache.org/derby/docs/10.2/ref/rrefattrib26867.html
Thomas
Pranav Aggarwal wrote:
Hi all,
I am new to Derby, just trying a small program which makes connection
to derby DB.
Following program I have written:
import java.sql.*;
class derby_connect
{
void connect() throws Exception
{
String driver="org.apache.derby.jdbc.EmbeddedDriver";
String dbName="mydb";
String connectionURL="jdbc:derby:"+dbName;
Connection conn=null;
try
{
Class.forName(driver);
}catch(java.lang.ClassNotFoundException e)
{
e.printStackTrace();
}
try
{
conn=DriverManager.getConnection(connectionURL);
System.out.println("Connection established!!!");
}
catch(Throwable e)
{e.printStackTrace();}
finally {conn.close();}
}//end of connect()
public static void main(String args[]) throws Exception
{
derby_connect dc=new derby_connect();
dc.connect();
}
}//end of class
The program resides in same directory where DB is residing. Now when
I run, I get the following error:
$ java derby_connect
java.sql.SQLException: Failed to start database 'mydb', see the next
exception for details.
at
org.apache.derby.impl.jdbc.SQLExceptionFactory40.getSQLException(Unknown
Source)
at org.apache.derby.impl.jdbc.Util.newEmbedSQLException(Unknown
Source)
at org.apache.derby.impl.jdbc.Util.newEmbedSQLException(Unknown
Source)
at
org.apache.derby.impl.jdbc.Util.generateCsSQLException(Unknown Source)
at
org.apache.derby.impl.jdbc.EmbedConnection.newSQLException(Unknown
Source)
at
org.apache.derby.impl.jdbc.EmbedConnection.bootDatabase(Unknown Source)
at org.apache.derby.impl.jdbc.EmbedConnection.<init>(Unknown
Source)
at org.apache.derby.impl.jdbc.EmbedConnection30.<init>(Unknown
Source)
at org.apache.derby.impl.jdbc.EmbedConnection40.<init>(Unknown
Source)
at org.apache.derby.jdbc.Driver40.getNewEmbedConnection(Unknown
Source)
at org.apache.derby.jdbc.InternalDriver.connect(Unknown Source)
at org.apache.derby.jdbc.AutoloadedDriver.connect(Unknown Source)
at java.sql.DriverManager.getConnection(DriverManager.java:582)
at java.sql.DriverManager.getConnection(DriverManager.java:207)
at derby_connect.connect(derby_connect.java:21)
at derby_connect.main(derby_connect.java:32)
Caused by: java.sql.SQLException: Failed to start database 'mydb',
see the next exception for details.
at
org.apache.derby.impl.jdbc.SQLExceptionFactory.getSQLException(Unknown
Source)
at
org.apache.derby.impl.jdbc.SQLExceptionFactory40.wrapArgsForTransportAcrossDRDA(Unknown
Source)
... 16 more
Exception in thread "main" java.lang.NullPointerException
at derby_connect.connect(derby_connect.java:26)
at derby_connect.main(derby_connect.java:32)
Can any one help me with this?
------------------------------------------------------------------------
Subject:
Problem with create table in Derby 10.2.2.0
From:
"Leo Alberto" <[EMAIL PROTECTED]>
Date:
Fri, 9 Feb 2007 19:07:58 +0100
To:
<[email protected]>
To:
<[email protected]>
Hy
I'm try to using Derby 10.2.2.0
<http://db.apache.org/derby/releases/release-10.2.2.0.cgi> in embedded
mode with the integrated plug-in environment in Eclipse 3.2.0.
Environment jre 1.6.0
I would create a table with this code :
*public* *boolean* tableCreation(Connection currentConn, String Table)
*throws* DatabaseDriverException {
*boolean* doCreateTable = *true*;
Statement stmt = *null*;
String createString = "create table " +
Table +
"(SAMPLE_ID int not null generate always as increment, " +
"KEY_ID long, " +
"KEY_INST_COUNT int, " +
"DATAOBJ blob (102400), " +
"unique(KEY_ID))";
*try* {
currentConn.setAutoCommit(*false*);
stmt = currentConn.createStatement();
DatabaseMetaData md = currentConn.getMetaData();
ResultSet rs = md.getTables(*null*, *null*, "%",
*null*);
*while* (rs.next()) {
System./out/.println("Elenco tabelle nel db " + rs.getString(3));
*if* (rs.getString(3).equals(tabella)) {
doCreateTable = *false*;
*break*;
}
}
*if* (doCreateTable) {
// execute
stmt.execute(createString); // _I'm
arriving here ang got the error_
doCreateTable = *true*;
}
currentConn.commit();
stmt.close();
} *catch* (SQLException e) {
*throw* *new* DatabaseDriverException("Error
create table", e);
}
*return* doCreateTable;
}/* End tableCreation */
the error is:
Syntax error: Encountered "," at line 1, column 88.
at
org.apache.derby.impl.jdbc.SQLExceptionFactory40.getSQLException(Unknown
Source)
at
org.apache.derby.impl.jdbc.Util.generateCsSQLException(Unknown Source)
at
org.apache.derby.impl.jdbc.TransactionResourceImpl.wrapInSQLException(Unknown
Source)
at
org.apache.derby.impl.jdbc.TransactionResourceImpl.handleException(Unknown
Source)
at
org.apache.derby.impl.jdbc.EmbedConnection.handleException(Unknown Source)
at
org.apache.derby.impl.jdbc.ConnectionChild.handleException(Unknown Source)
at org.apache.derby.impl.jdbc.EmbedStatement.execute(Unknown
Source)Error create table
at org.apache.derby.impl.jdbc.EmbedStatement.execute(Unknown
Source)
at dds.dbdrivers.DerbyDriver.tableCreation(_DerbyDriver.java:257_)
at provaDB.main(_provaDB.java:39_)
Caused by: _java.sql.SQLException_: Syntax error: Encountered "," at
line 1, column 88.
at
org.apache.derby.impl.jdbc.SQLExceptionFactory.getSQLException(Unknown
Source)
at
org.apache.derby.impl.jdbc.SQLExceptionFactory40.wrapArgsForTransportAcrossDRDA(Unknown
Source)
... 10 more
from errorlog.txt generated:
----------------------------------------------------------------
2007-02-09 17:31:01.452 GMT:
Booting Derby version The Apache Software Foundation - Apache Derby -
10.2.2.0 - (485682): instance c013800d-0110-a78e-d8b1-ffffa2db3c51
on database directory C:\DdsAppDb\DbDOMAIN_(7)
Database Class Loader started - derby.database.classpath=''
2007-02-09 17:31:10.786 GMT Thread[main,5,main] (XID = 122),
(SESSIONID = 0), (DATABASE = DbDOMAIN_(7)), (DRDAID = null), Cleanup
action starting
2007-02-09 17:31:10.786 GMT Thread[main,5,main] (XID = 122),
(SESSIONID = 0), (DATABASE = DbDOMAIN_(7)), (DRDAID = null), Failed
Statement is:
<my add>
1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678
create table POSITION (SAMPLE_ID int not null generated always as
identity, KEY_ID long, KEY_INST_COUNT int, DATAOBJ blob (102400),
unique(KEY_ID))
ERROR 42X01: Syntax error: Encountered "," at line 1, column 88.
at
org.apache.derby.iapi.error.StandardException.newException(Unknown Source)
at
org.apache.derby.impl.sql.compile.ParserImpl.parseStatement(Unknown
Source)
at
org.apache.derby.impl.sql.GenericStatement.prepMinion(Unknown Source)
at org.apache.derby.impl.sql.GenericStatement.prepare(Unknown
Source)
at
org.apache.derby.impl.sql.conn.GenericLanguageConnectionContext.prepareInternalStatement(Unknown
Source)
at org.apache.derby.impl.jdbc.EmbedStatement.execute(Unknown
Source)
at org.apache.derby.impl.jdbc.EmbedStatement.execute(Unknown
Source)
at dds.dbdrivers.DerbyDriver.tableCreation(DerbyDriver.java:257)
at provaDB.main(provaDB.java:39)
Cleanup action completed
I would be very glad if someone can help me understand wath is wrong!
thanks in advance
Alberto Leo
------------------------------------------------------------------------
Subject:
Re: Problem with create table in Derby 10.2.2.0
From:
"Mamta Satoor" <[EMAIL PROTECTED]>
Date:
Fri, 9 Feb 2007 10:45:51 -0800
To:
"Derby Discussion" <[email protected]>
To:
"Derby Discussion" <[email protected]>
Leo,
You need to use BIGINT rather than long for KEY_ID column.
Mamta
On 2/9/07, *Leo Alberto* <[EMAIL PROTECTED]
<mailto:[EMAIL PROTECTED]>> wrote:
Hy
I'm try to using Derby 10.2.2.0
<http://db.apache.org/derby/releases/release-10.2.2.0.cgi> in
embedded mode with the integrated plug-in environment in Eclipse
3.2.0. Environment jre 1.6.0
I would create a table with this code :
*public* * boolean* tableCreation(Connection currentConn, String
Table)
*throws* DatabaseDriverException {
*boolean* doCreateTable = *true*;
Statement stmt = *null*;
String createString = "create table " +
Table +
"(SAMPLE_ID int not null generate always as increment, " +
"KEY_ID long, " +
"KEY_INST_COUNT int, " +
"DATAOBJ blob (102400), " +
"unique(KEY_ID))";
*try* {
currentConn.setAutoCommit (*false*);
stmt = currentConn.createStatement();
DatabaseMetaData md = currentConn.getMetaData();
ResultSet rs = md.getTables(*null*, *null*,
"%", * null*);
*while* (rs.next()) {
System./out/ .println("Elenco tabelle nel db " + rs.getString(3));
*if* (rs.getString(3).equals(tabella)) {
doCreateTable = * false*;
*break*;
}
}
*if* (doCreateTable) {
// execute
stmt. execute(createString); // _I'm
arriving here ang got the error_
doCreateTable = * true*;
}
currentConn.commit();
stmt.close();
} *catch* (SQLException e) {
*throw* *new* DatabaseDriverException("Error
create table", e);
}
*return* doCreateTable;
}/* End tableCreation */
the error is:
Syntax error: Encountered "," at line 1, column 88.
at
org.apache.derby.impl.jdbc.SQLExceptionFactory40.getSQLException(Unknown
Source)
at
org.apache.derby.impl.jdbc.Util.generateCsSQLException(Unknown
Source)
at
org.apache.derby.impl.jdbc.TransactionResourceImpl.wrapInSQLException(Unknown
Source)
at
org.apache.derby.impl.jdbc.TransactionResourceImpl.handleException(Unknown
Source)
at
org.apache.derby.impl.jdbc.EmbedConnection.handleException(Unknown
Source)
at
org.apache.derby.impl.jdbc.ConnectionChild.handleException(Unknown
Source)
at
org.apache.derby.impl.jdbc.EmbedStatement.execute(Unknown
Source)Error create table
at
org.apache.derby.impl.jdbc.EmbedStatement.execute(Unknown Source)
at dds.dbdrivers.DerbyDriver.tableCreation(_
DerbyDriver.java:257_)
at provaDB.main(_provaDB.java:39 _)
Caused by: _java.sql.SQLException_ : Syntax error: Encountered ","
at line 1, column 88.
at
org.apache.derby.impl.jdbc.SQLExceptionFactory.getSQLException(Unknown
Source)
at
org.apache.derby.impl.jdbc.SQLExceptionFactory40.wrapArgsForTransportAcrossDRDA(Unknown
Source)
... 10 more
from errorlog.txt generated:
----------------------------------------------------------------
2007-02-09 17:31:01.452 GMT:
Booting Derby version The Apache Software Foundation - Apache
Derby - 10.2.2.0 <http://10.2.2.0/> - (485682): instance
c013800d-0110-a78e-d8b1-ffffa2db3c51
on database directory C:\DdsAppDb\DbDOMAIN_(7)
Database Class Loader started - derby.database.classpath=''
2007-02-09 17:31:10.786 GMT Thread[main,5,main] (XID = 122),
(SESSIONID = 0), (DATABASE = DbDOMAIN_(7)), (DRDAID = null),
Cleanup action starting
2007-02-09 17:31:10.786 GMT Thread[main,5,main] (XID = 122),
(SESSIONID = 0), (DATABASE = DbDOMAIN_(7)), (DRDAID = null),
Failed Statement is:
<my add>
1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678
create table POSITION (SAMPLE_ID int not null generated always as
identity, KEY_ID long, KEY_INST_COUNT int, DATAOBJ blob (102400),
unique(KEY_ID))
ERROR 42X01: Syntax error: Encountered "," at line 1, column 88.
at
org.apache.derby.iapi.error.StandardException.newException(Unknown
Source)
at
org.apache.derby.impl.sql.compile.ParserImpl.parseStatement(Unknown
Source)
at
org.apache.derby.impl.sql.GenericStatement.prepMinion(Unknown Source)
at
org.apache.derby.impl.sql.GenericStatement.prepare(Unknown Source)
at
org.apache.derby.impl.sql.conn.GenericLanguageConnectionContext.prepareInternalStatement(Unknown
Source)
at
org.apache.derby.impl.jdbc.EmbedStatement.execute(Unknown Source)
at
org.apache.derby.impl.jdbc.EmbedStatement.execute(Unknown Source)
at
dds.dbdrivers.DerbyDriver.tableCreation(DerbyDriver.java:257)
at provaDB.main(provaDB.java:39)
Cleanup action completed
I would be very glad if someone can help me understand wath is wrong!
thanks in advance
Alberto Leo