473,395 Members | 1,457 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Derby database on localhost

112 100+
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:

Expand|Select|Wrap|Line Numbers
  1. java.sql.SQLNonTransientConnectionException: Insufficient data while reading fro
  2. m the network - expected a minimum of 6 bytes and received only -1 bytes.  The c
  3. onnection has been terminated.
  4.         at org.apache.derby.client.am.SQLExceptionFactory40.getSQLException(Unkn
  5. own Source)
  6.         at org.apache.derby.client.am.SqlException.getSQLException(Unknown Sourc
  7. e)
  8.         at org.apache.derby.jdbc.ClientDriver.connect(Unknown Source)
  9.         at java.sql.DriverManager.getConnection(DriverManager.java:582)
  10.         at java.sql.DriverManager.getConnection(DriverManager.java:207)
  11.         at DataBaseReader.createOnlineDB(DataBaseReader.java:142)
  12.         at ToTheGallows.main(ToTheGallows.java:31)
  13. Caused by: org.apache.derby.client.am.DisconnectException: Insufficient data whi
  14. le reading from the network - expected a minimum of 6 bytes and received only -1
  15.  bytes.  The connection has been terminated.
  16.         at org.apache.derby.client.net.Reply.fill(Unknown Source)
  17.         at org.apache.derby.client.net.Reply.ensureALayerDataInBuffer(Unknown So
  18. urce)
  19.         at org.apache.derby.client.net.Reply.readDssHeader(Unknown Source)
  20.         at org.apache.derby.client.net.Reply.startSameIdChainParse(Unknown Sourc
  21. e)
  22.         at org.apache.derby.client.net.NetConnectionReply.readExchangeServerAttr
  23. ibutes(Unknown Source)
  24.         at org.apache.derby.client.net.NetConnection.readServerAttributesAndKeyE
  25. xchange(Unknown Source)
  26.         at org.apache.derby.client.net.NetConnection.flowServerAttributesAndKeyE
  27. xchange(Unknown Source)
  28.         at org.apache.derby.client.net.NetConnection.flowUSRIDONLconnect(Unknown
  29.  Source)
  30.         at org.apache.derby.client.net.NetConnection.flowConnect(Unknown Source)
  31.  
  32.         at org.apache.derby.client.net.NetConnection.<init>(Unknown Source)
  33.         at org.apache.derby.client.net.NetConnection40.<init>(Unknown Source)
  34.         at org.apache.derby.client.net.ClientJDBCObjectFactoryImpl40.newNetConne
  35. ction(Unknown Source)
  36.         ... 5 more
if you wouldnt mind taking a peek at my code here is the method where the magic happens:
Expand|Select|Wrap|Line Numbers
  1.     public static void createOnlineDB(String DBName)
  2.     {
  3.         try{
  4.               Class.forName("org.apache.derby.jdbc.EmbeddedDriver").newInstance();
  5.             Debug.println("class loaded.");
  6.             System.setProperty("derby.drda.startNetworkServer","true");
  7.             Debug.println("startNetworkServer property set true");
  8.             conn = DriverManager.getConnection("jdbc:derby://localhost:80/ttg/"+DBName+";create=true");
  9.             conn.commit();
  10.             conn.close();
  11.         }catch(Exception e){e.printStackTrace();}
  12.     }
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
Apr 14 '08 #1
14 8895
JosAH
11,448 Expert 8TB
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
Apr 15 '08 #2
drsmooth
112 100+
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:
Expand|Select|Wrap|Line Numbers
  1.     public static void createOnlineDB(String DBName)
  2.     {
  3.         try{
  4.             Class.forName("org.apache.derby.jdbc.ClientDriver").newInstance();
  5.             Debug.println("class loaded.");
  6.             System.setProperty("derby.drda.startNetworkServer","true");
  7.             Debug.println("startNetworkServer property set true");
  8.             conn = DriverManager.getConnection("jdbc:derby://localhost:80/ttg/"+DBName+";create=true");
  9.             conn.commit();
  10.             conn.close();
  11.         }catch(Exception e){e.printStackTrace();}
  12.     }
thanks
ken
Apr 15 '08 #3
drsmooth
112 100+
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
Apr 16 '08 #4
JosAH
11,448 Expert 8TB
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
Apr 17 '08 #5
drsmooth
112 100+
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.
Apr 17 '08 #6
pronerd
392 Expert 256MB
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?
Apr 17 '08 #7
drsmooth
112 100+
i tried adjusting the port, now i got this:
Expand|Select|Wrap|Line Numbers
  1. java.sql.SQLNonTransientConnectionException: java.net.ConnectException : Error connecting to server localhost on port 1026 with message Connection refused: connect.
  2.     at org.apache.derby.client.am.SQLExceptionFactory40.getSQLException(Unknown Source)
  3.     at org.apache.derby.client.am.SqlException.getSQLException(Unknown Source)
  4.     at org.apache.derby.jdbc.ClientDriver.connect(Unknown Source)
  5.     at java.sql.DriverManager.getConnection(DriverManager.java:582)
  6.     at java.sql.DriverManager.getConnection(DriverManager.java:207)
  7.     at DataBaseReader.createOnlineDB(DataBaseReader.java:142)
  8.     at ToTheGallows.main(ToTheGallows.java:30)
  9. Caused by: org.apache.derby.client.am.DisconnectException: java.net.ConnectException : Error connecting to server localhost on port 1026 with message Connection refused: connect.
  10.     at org.apache.derby.client.net.NetAgent.<init>(Unknown Source)
  11.     at org.apache.derby.client.net.NetConnection.newAgent_(Unknown Source)
  12.     at org.apache.derby.client.am.Connection.<init>(Unknown Source)
  13.     at org.apache.derby.client.net.NetConnection.<init>(Unknown Source)
  14.     at org.apache.derby.client.net.NetConnection40.<init>(Unknown Source)
  15.     at org.apache.derby.client.net.ClientJDBCObjectFactoryImpl40.newNetConnection(Unknown Source)
  16.     ... 5 more
  17. Caused by: java.net.ConnectException: Connection refused: connect
  18.     at java.net.PlainSocketImpl.socketConnect(Native Method)
  19.     at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:333)
  20.     at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:195)
  21.     at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:182)
  22.     at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:366)
  23.     at java.net.Socket.connect(Socket.java:519)
  24.     at java.net.Socket.connect(Socket.java:469)
  25.     at java.net.Socket.<init>(Socket.java:366)
  26.     at java.net.Socket.<init>(Socket.java:179)
  27.     at javax.net.DefaultSocketFactory.createSocket(SocketFactory.java:196)
  28.     at org.apache.derby.client.net.OpenSocketAction.run(Unknown Source)
  29.     at java.security.AccessController.doPrivileged(Native Method)
  30.     ... 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
Apr 17 '08 #8
drsmooth
112 100+
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:
Expand|Select|Wrap|Line Numbers
  1.     public static void createOnlineDB(String DBName)
  2.     {
  3.         try{
  4.             Class.forName("com.mysql.jdbc.Driver").newInstance();
  5.             Class.forName("org.gjt.mm.mysql.Driver").newInstance();
  6.             Debug.println("class loaded.");
  7.  
  8.             conn = DriverManager.getConnection("jdbc:mysql://192.168.2.3:80/ttg/"+DBName+";create=true");
  9.             conn.commit();
  10.             conn.close();
  11.         }catch(Exception e){e.printStackTrace();}
  12.     }
and the error:
Expand|Select|Wrap|Line Numbers
  1. com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure
  2.  
  3. Last packet sent to the server was 0 ms ago.
  4.     at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
  5.     at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
  6.     at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
  7.     at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
  8.     at com.mysql.jdbc.Util.handleNewInstance(Util.java:406)
  9.     at com.mysql.jdbc.SQLError.createCommunicationsException(SQLError.java:1074)
  10.     at com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2103)
  11.     at com.mysql.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:718)
  12.     at com.mysql.jdbc.JDBC4Connection.<init>(JDBC4Connection.java:46)
  13.     at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
  14.     at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
  15.     at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
  16.     at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
  17.     at com.mysql.jdbc.Util.handleNewInstance(Util.java:406)
  18.     at com.mysql.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:302)
  19.     at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:282)
  20.     at java.sql.DriverManager.getConnection(DriverManager.java:582)
  21.     at java.sql.DriverManager.getConnection(DriverManager.java:207)
  22.     at DataBaseReader.createOnlineDB(DataBaseReader.java:143)
  23.     at ToTheGallows.main(ToTheGallows.java:32)
  24. Caused by: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure
this database stuff is a pain in the neck lol

thanks,
ken
Apr 19 '08 #9
JosAH
11,448 Expert 8TB
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
Apr 20 '08 #10
drsmooth
112 100+
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
Apr 20 '08 #11
JosAH
11,448 Expert 8TB
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
Apr 20 '08 #12
drsmooth
112 100+
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
Apr 20 '08 #13
drsmooth
112 100+
finally!! after many hours wsted to this ive gotten it to work!

thanks alot for all your help
Apr 20 '08 #14
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.
Nov 17 '14 #15

Sign in to post your reply or Sign up for a free account.

Similar topics

8
by: peter | last post by:
I have taken over the website duties at work. I am still learning PHP and MySQL. I want to have a form where the user enters some finacial info and it is stored in a database. It, obviously,...
3
by: frothpoker | last post by:
Guys, I'm sure this has been asked a million times but I can't seem to formulate a google search that returns what i'm looking for. I've go a dev and live environment. Currently the DB...
4
by: dougans | last post by:
Hey there, Hope someone can help me, completely stuck with immigrating from php4 to OOP based php5. == index.php -- include(database.inc.php);
1
by: buzzko | last post by:
Hi! I hope someone can help me. I want to connect to a Microsoft SQL Server 2005 Express Edition database programming in C++. I am using Netbeans (with g++ compiler) platform over Windows because...
20
by: knellim | last post by:
Hi All, I am trying to configure php with IBM-DB2 and I get the followinng when i run the configure command ./configure --with-pdo-odbc=ibm-db2,/opt/IBM/db2/V8.1/ THE OUTPUT: checking for...
2
by: knellim | last post by:
I can connect to DB2 on the command line on the server. db2=>connect to mytest user knellim using xxxx Database Connection Information Database server = Apache Derby CSS10050 ...
0
by: gaya3 | last post by:
Hi, For our swing application we are using derby database. Since its desktoop application, we are providing the application as jar to the clients. But issue is in finding the database. Derby...
6
by: knellim | last post by:
Hello All, I am using PHP to connect to derby/db2 database. I want to implement unix_timestamp() function (used in mysql) to its equivalent in derby database. I found the equivalent as select {fn...
0
by: improvcornartist | last post by:
I created a derby database backed swing application. I then wanted to archive the database for distribution with the application, the final goal being a single jar. Pre-archive queries that ran in no...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.