• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Runtime Exceptions for JDBC program using Derby Client in Netbeans

 
Kasiraj Murugesa pandian
Greenhorn
Posts: 21
Java Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Sheriff
Posts: 21416
33
Eclipse IDE Firefox Browser MySQL Database
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 21
Java Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic