I hope you are all ok with the frequency of this question following my last, im struggling alot with this database stuff. and i really appreciate all the help from this forum, many a time you have saved my computer from a trip out my window lol.
now im trying to create a derby database at runtime in my java code...ive created and used databases on the hard drive, but now im trying to move toward the net and started with the localhost.
im getting this error consistanlty at runtime: - java.sql.SQLNonTransientConnectionException: Insufficient data while reading fro
-
m the network - expected a minimum of 6 bytes and received only -1 bytes. The c
-
onnection has been terminated.
-
at org.apache.derby.client.am.SQLExceptionFactory40.getSQLException(Unkn
-
own Source)
-
at org.apache.derby.client.am.SqlException.getSQLException(Unknown Sourc
-
e)
-
at org.apache.derby.jdbc.ClientDriver.connect(Unknown Source)
-
at java.sql.DriverManager.getConnection(DriverManager.java:582)
-
at java.sql.DriverManager.getConnection(DriverManager.java:207)
-
at DataBaseReader.createOnlineDB(DataBaseReader.java:142)
-
at ToTheGallows.main(ToTheGallows.java:31)
-
Caused by: org.apache.derby.client.am.DisconnectException: Insufficient data whi
-
le reading from the network - expected a minimum of 6 bytes and received only -1
-
bytes. The connection has been terminated.
-
at org.apache.derby.client.net.Reply.fill(Unknown Source)
-
at org.apache.derby.client.net.Reply.ensureALayerDataInBuffer(Unknown So
-
urce)
-
at org.apache.derby.client.net.Reply.readDssHeader(Unknown Source)
-
at org.apache.derby.client.net.Reply.startSameIdChainParse(Unknown Sourc
-
e)
-
at org.apache.derby.client.net.NetConnectionReply.readExchangeServerAttr
-
ibutes(Unknown Source)
-
at org.apache.derby.client.net.NetConnection.readServerAttributesAndKeyE
-
xchange(Unknown Source)
-
at org.apache.derby.client.net.NetConnection.flowServerAttributesAndKeyE
-
xchange(Unknown Source)
-
at org.apache.derby.client.net.NetConnection.flowUSRIDONLconnect(Unknown
-
Source)
-
at org.apache.derby.client.net.NetConnection.flowConnect(Unknown Source)
-
-
at org.apache.derby.client.net.NetConnection.<init>(Unknown Source)
-
at org.apache.derby.client.net.NetConnection40.<init>(Unknown Source)
-
at org.apache.derby.client.net.ClientJDBCObjectFactoryImpl40.newNetConne
-
ction(Unknown Source)
-
... 5 more
if you wouldnt mind taking a peek at my code here is the method where the magic happens: -
public static void createOnlineDB(String DBName)
-
{
-
try{
-
Class.forName("org.apache.derby.jdbc.EmbeddedDriver").newInstance();
-
Debug.println("class loaded.");
-
System.setProperty("derby.drda.startNetworkServer","true");
-
Debug.println("startNetworkServer property set true");
-
conn = DriverManager.getConnection("jdbc:derby://localhost:80/ttg/"+DBName+";create=true");
-
conn.commit();
-
conn.close();
-
}catch(Exception e){e.printStackTrace();}
-
}
that starts at line 135.
debug is basically system.out.println with an on/off switch. i coded it so i could quickly shut off unsighlty things when showing my friends the work so far...
i really appreciate any help,
thanks,
ken
14 8674
You're using the wrong driver, don't use the EmbeddedDriver but use the ClientDriver.
See the 'getting started' manual 'activity 4' for a detailed explanation.
kind regards,
Jos
You're using the wrong driver, don't use the EmbeddedDriver but use the ClientDriver.
See the 'getting started' manual 'activity 4' for a detailed explanation.
kind regards,
Jos
right...that was actually a mistake, i changed it on my code in referce to some crazy example i saw online, this is the updated code, still with the same problem: -
public static void createOnlineDB(String DBName)
-
{
-
try{
-
Class.forName("org.apache.derby.jdbc.ClientDriver").newInstance();
-
Debug.println("class loaded.");
-
System.setProperty("derby.drda.startNetworkServer","true");
-
Debug.println("startNetworkServer property set true");
-
conn = DriverManager.getConnection("jdbc:derby://localhost:80/ttg/"+DBName+";create=true");
-
conn.commit();
-
conn.close();
-
}catch(Exception e){e.printStackTrace();}
-
}
thanks
ken
i read the manual activity 4, checked the example code against mine, and they seem to line up, is there something else that could be wrong? ive been getting quite frustrated with these databases, unfourtunately, they are quite pivotal to handling data...lol...even an explanation of what that error means may help, i tried google, but nothing came up but and old mailng list post with no response.
thanks,
ken
i read the manual activity 4, checked the example code against mine, and they seem to line up, is there something else that could be wrong? ive been getting quite frustrated with these databases, unfourtunately, they are quite pivotal to handling data...lol...even an explanation of what that error means may help, i tried google, but nothing came up but and old mailng list post with no response.
thanks,
ken
The error message is simple: you don't have a connection with the server. Have
you actually started a server? I'll check the documentation when I have some time.
kind regards,
Jos
The error message is simple: you don't have a connection with the server. Have
you actually started a server? I'll check the documentation when I have some time.
kind regards,
Jos
i have a localhost server set up on my computer already, im not really sure how it works, but it does as far as i know.
I have not worked with Derby so I maybe off base here. I noticed you are running it on port 80. That port is a reserved port for web servers. So using that port can cause two problems.
First if you have a web server running too it will conflict with the database.
Second most OS's now require that you have admin(root) privileges to run services on reserved ports. So if the account that the Derby service is running on maybe there is a reason for this.
I would try running it on port 1025 or higher. Also have you checked the log files to make sure that Derby is successfully starting?
i tried adjusting the port, now i got this: - java.sql.SQLNonTransientConnectionException: java.net.ConnectException : Error connecting to server localhost on port 1026 with message Connection refused: connect.
-
at org.apache.derby.client.am.SQLExceptionFactory40.getSQLException(Unknown Source)
-
at org.apache.derby.client.am.SqlException.getSQLException(Unknown Source)
-
at org.apache.derby.jdbc.ClientDriver.connect(Unknown Source)
-
at java.sql.DriverManager.getConnection(DriverManager.java:582)
-
at java.sql.DriverManager.getConnection(DriverManager.java:207)
-
at DataBaseReader.createOnlineDB(DataBaseReader.java:142)
-
at ToTheGallows.main(ToTheGallows.java:30)
-
Caused by: org.apache.derby.client.am.DisconnectException: java.net.ConnectException : Error connecting to server localhost on port 1026 with message Connection refused: connect.
-
at org.apache.derby.client.net.NetAgent.<init>(Unknown Source)
-
at org.apache.derby.client.net.NetConnection.newAgent_(Unknown Source)
-
at org.apache.derby.client.am.Connection.<init>(Unknown Source)
-
at org.apache.derby.client.net.NetConnection.<init>(Unknown Source)
-
at org.apache.derby.client.net.NetConnection40.<init>(Unknown Source)
-
at org.apache.derby.client.net.ClientJDBCObjectFactoryImpl40.newNetConnection(Unknown Source)
-
... 5 more
-
Caused by: java.net.ConnectException: Connection refused: connect
-
at java.net.PlainSocketImpl.socketConnect(Native Method)
-
at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:333)
-
at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:195)
-
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:182)
-
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:366)
-
at java.net.Socket.connect(Socket.java:519)
-
at java.net.Socket.connect(Socket.java:469)
-
at java.net.Socket.<init>(Socket.java:366)
-
at java.net.Socket.<init>(Socket.java:179)
-
at javax.net.DefaultSocketFactory.createSocket(SocketFactory.java:196)
-
at org.apache.derby.client.net.OpenSocketAction.run(Unknown Source)
-
at java.security.AccessController.doPrivileged(Native Method)
-
... 11 more
the localhost is set up to lsten on port 80, my dad used it for something else before, im not really too sure on how to work with that...
thanks
ken
could the fact that i have apache web server installed in the localhost effect it? i switched over and now im trying to make a mysql database using the mysql conntector/j and im getting a communications link failure...
here is my new code: - public static void createOnlineDB(String DBName)
-
{
-
try{
-
Class.forName("com.mysql.jdbc.Driver").newInstance();
-
Class.forName("org.gjt.mm.mysql.Driver").newInstance();
-
Debug.println("class loaded.");
-
-
conn = DriverManager.getConnection("jdbc:mysql://192.168.2.3:80/ttg/"+DBName+";create=true");
-
conn.commit();
-
conn.close();
-
}catch(Exception e){e.printStackTrace();}
-
}
and the error: - com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure
-
-
Last packet sent to the server was 0 ms ago.
-
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
-
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
-
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
-
at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
-
at com.mysql.jdbc.Util.handleNewInstance(Util.java:406)
-
at com.mysql.jdbc.SQLError.createCommunicationsException(SQLError.java:1074)
-
at com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2103)
-
at com.mysql.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:718)
-
at com.mysql.jdbc.JDBC4Connection.<init>(JDBC4Connection.java:46)
-
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
-
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
-
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
-
at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
-
at com.mysql.jdbc.Util.handleNewInstance(Util.java:406)
-
at com.mysql.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:302)
-
at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:282)
-
at java.sql.DriverManager.getConnection(DriverManager.java:582)
-
at java.sql.DriverManager.getConnection(DriverManager.java:207)
-
at DataBaseReader.createOnlineDB(DataBaseReader.java:143)
-
at ToTheGallows.main(ToTheGallows.java:32)
-
Caused by: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure
this database stuff is a pain in the neck lol
thanks,
ken
i switched over and now im trying to make a mysql database using the mysql conntector/j
If you wildly switch over to another DBMS if a previous DBMS doesn't work think
of it: umpty of people are working succesfully with that previous DBMS. How come?
I don't think it's the DBMS to blaim here; a bit more reading could've done the
job. Now you have to start reading all the documentation for your new DBMS.
kind regards,
Jos
well i made the desicion to switch as more of a convience thing, i wanted to be able to acess the database not just from derby but other internet type apps e.g php and stuff like that...bottom line, neither want to work for me lol
well i made the desicion to switch as more of a convience thing, i wanted to be able to acess the database not just from derby but other internet type apps e.g php and stuff like that...bottom line, neither want to work for me lol
Note that we're not living in an ideal world, i.e. after you have created a database
with software package X (e.g. Derby), you can't access your data with another
software package Y (e.g. MySQL, DB/2, Oracle, you name them).
kind regards,
Jos
Note that we're not living in an ideal world, i.e. after you have created a database
with software package X (e.g. Derby), you can't access your data with another
software package Y (e.g. MySQL, DB/2, Oracle, you name them).
kind regards,
Jos
right...thats why i switched over to using mysql
finally!! after many hours wsted to this ive gotten it to work!
thanks alot for all your help
Hi, Are you using Derby stored procedure with user defined types as parameter(s)?, if this is the case the jar version using from derby is older, From which application you called this procedure?
I faced this error with my Derby network server frequently.
You can keep same jar file in you application as well and derby while booting up will solve this problem.
Post your reply Sign in to post your reply or Sign up for a free account.
Similar topics
8 posts
views
Thread by peter |
last post: by
|
3 posts
views
Thread by frothpoker |
last post: by
| | | | | | | | | | | | | | | | | |