Meaningless Drivel is fun!*
The moose likes JDBC and the fly likes Runtime Exceptions for JDBC program using Derby Client in Netbeans Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Runtime Exceptions for JDBC program using Derby Client in Netbeans" Watch "Runtime Exceptions for JDBC program using Derby Client in Netbeans" New topic
Author

Runtime Exceptions for JDBC program using Derby Client in Netbeans

Kasiraj Murugesa pandian
Greenhorn

Joined: Sep 09, 2011
Posts: 21

I was trying to connect to a simple database through netbeans using the Type 4 connectivity ( Derby ) . Although i could successfully compile the following code for it :

Source Code

I am getting the following Exception :

Exception
Exception in thread "main" java.sql.SQLNonTransientConnectionException: java.net.ConnectException : Error connecting to server localhost on port 1527 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:579)
at java.sql.DriverManager.getConnection(DriverManager.java:243)
at javaapplication2.JavaApplication2.main(JavaApplication2.java:22)
Caused by: org.apache.derby.client.am.DisconnectException: java.net.ConnectException : Error connecting to server localhost on port 1527 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)
... 4 more
Caused by: java.net.ConnectException: Connection refused: connect
at java.net.DualStackPlainSocketImpl.connect0(Native Method)
at java.net.DualStackPlainSocketImpl.socketConnect(DualStackPlainSocketImpl.java:69)
at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:337)
at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:198)
at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:180)
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:157)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:391)
at java.net.Socket.connect(Socket.java:579)
at java.net.Socket.connect(Socket.java:528)
at java.net.Socket.<init>(Socket.java:425)
at java.net.Socket.<init>(Socket.java:208)
at javax.net.DefaultSocketFactory.createSocket(SocketFactory.java:271)
at org.apache.derby.client.net.OpenSocketAction.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
... 10 more
Java Result: 1
BUILD SUCCESSFUL (total time: 3 seconds)


even though i've imported .jar file for the Derby client required , i couldn't overcome this exception .

So it would be really great if you could Kindly help me to overcome this Excception to run my first JDBC Program

Thanks in Advance

Regards,
Kasiraj
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    8

Yeah. That's an extremely common question about JDBC, I'm sure you would have found this answer if you had searched the forum:

That means you aren't running a server on your computer (localhost) which is listening at port 1527. Did you start the Derby server? On your computer? Is it listening at port 1527?
Kasiraj Murugesa pandian
Greenhorn

Joined: Sep 09, 2011
Posts: 21

Paul Clapham wrote:Yeah. That's an extremely common question about JDBC, I'm sure you would have found this answer if you had searched the forum:

That means you aren't running a server on your computer (localhost) which is listening at port 1527. Did you start the Derby server? On your computer? Is it listening at port 1527?


Wow ! That really helped . At first , i dint start the Server and secondly i dint provide the username and password in the getConnection Method .

The same program is executing Perfect now .

Thanks Dude !

Regards,
Kasi
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Runtime Exceptions for JDBC program using Derby Client in Netbeans