Results 1 to 10 of 10
  1. #1
    nonabhai is offline Member
    Join Date
    Mar 2010
    Posts
    20
    Rep Power
    0

    Default Jar file does not work with database (Hibernate)

    I have created an application using hibernate... It works fine with database when I run it through Netbeans. But when I build application (using Clean and Build tool) it does not work with database :( ... Help me please...

  2. #2
    r035198x is offline Senior Member
    Join Date
    Aug 2009
    Posts
    2,388
    Rep Power
    7

    Default

    Explain what you mean by "it does not work".

  3. #3
    nonabhai is offline Member
    Join Date
    Mar 2010
    Posts
    20
    Rep Power
    0

    Default

    Thnx 4 ur response r035198x. Does not work means tht Jar file can not find any database

  4. #4
    r035198x is offline Senior Member
    Join Date
    Aug 2009
    Posts
    2,388
    Rep Power
    7

    Default

    Please post the exact error message that you are getting.

  5. #5
    nonabhai is offline Member
    Join Date
    Mar 2010
    Posts
    20
    Rep Power
    0

    Default

    It does not show any error when I try to save or retrieve data. But neither it stores data to database nor retrieve, I think I have build the project without database... Do u have any idea how to build the project with database (hibernate database) in netbeans? thnx for ur response...

  6. #6
    r035198x is offline Senior Member
    Join Date
    Aug 2009
    Posts
    2,388
    Rep Power
    7

    Default

    Are you hiding exceptions in your code then? Do you have e.printStackTrace() in all your catch blocks? You need to find out what exceptions are being thrown when you run your program outside an IDE.
    P.S The phrases "build project with database" and "hibernate database" do not make much sense so please stop using them. Concentrate on describing what you are doing and the output you are getting.

  7. #7
    nonabhai is offline Member
    Join Date
    Mar 2010
    Posts
    20
    Rep Power
    0

    Default

    This is the error message which i get...
    "org.hibernate.JDBCConnectionException: Cannot open connection"

  8. #8
    r035198x is offline Senior Member
    Join Date
    Aug 2009
    Posts
    2,388
    Rep Power
    7

    Default

    That is not the only line in your error logs.

  9. #9
    nonabhai is offline Member
    Join Date
    Mar 2010
    Posts
    20
    Rep Power
    0

    Default

    Below is the complete error message

    WARNING: SQL Error: 40000, SQLState: 08001
    May 21, 2010 4:25:11 PM org.hibernate.util.JDBCExceptionReporter logExceptions
    SEVERE: java.net.ConnectException : Error connecting to server localhost on port
    1527 with message Connection refused: connect.
    Exception in thread "AWT-EventQueue-0" org.hibernate.exception.JDBCConnectionException: Cannot open connection
    at org.hibernate.exception.SQLStateConverter.convert( SQLStateConverter.java:74)
    at org.hibernate.exception.JDBCExceptionHelper.conver t(JDBCExceptionHelper.java:43)
    at org.hibernate.exception.JDBCExceptionHelper.conver t(JDBCExceptionHelper.java:29)
    at org.hibernate.jdbc.ConnectionManager.openConnectio n(ConnectionManager.java:426)
    at org.hibernate.jdbc.ConnectionManager.getConnection (ConnectionManager.java:144)
    at org.hibernate.jdbc.AbstractBatcher.prepareQuerySta tement(AbstractBatcher.java:139)
    at org.hibernate.loader.Loader.prepareQueryStatement( Loader.java:1547)
    at org.hibernate.loader.Loader.doQuery(Loader.java:67 3)
    at org.hibernate.loader.Loader.doQueryAndInitializeNo nLazyCollections(Loader.java:236)
    at org.hibernate.loader.Loader.doList(Loader.java:222 0)
    at org.hibernate.loader.Loader.listIgnoreQueryCache(L oader.java:2104)
    at org.hibernate.loader.Loader.list(Loader.java:2099)
    at org.hibernate.loader.hql.QueryLoader.list(QueryLoa der.java:378)
    at org.hibernate.hql.ast.QueryTranslatorImpl.list(Que ryTranslatorImpl.java:338)
    at org.hibernate.engine.query.HQLQueryPlan.performLis t(HQLQueryPlan.java:172)
    at org.hibernate.impl.SessionImpl.list(SessionImpl.ja va:1121)
    at org.hibernate.impl.QueryImpl.list(QueryImpl.java:7 9)
    at ajmalispatientdatamanager.StartPage.searchMethod(S tartPage.java:852)
    at ajmalispatientdatamanager.StartPage.SearchBtnActio nPerformed(StartPage.java:599)
    at ajmalispatientdatamanager.StartPage.access$900(Sta rtPage.java:33)
    at ajmalispatientdatamanager.StartPage$8.actionPerfor med(StartPage.java:382)
    at javax.swing.AbstractButton.fireActionPerformed(Unk nown Source)
    at javax.swing.AbstractButton$Handler.actionPerformed (Unknown Source)
    at javax.swing.DefaultButtonModel.fireActionPerformed (Unknown Source)
    at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
    at javax.swing.plaf.basic.BasicButtonListener.mouseRe leased(Unknown Source)
    at java.awt.Component.processMouseEvent(Unknown Source)
    at javax.swing.JComponent.processMouseEvent(Unknown Source)
    at java.awt.Component.processEvent(Unknown Source)
    at java.awt.Container.processEvent(Unknown Source)
    at java.awt.Component.dispatchEventImpl(Unknown Source)
    at java.awt.Container.dispatchEventImpl(Unknown Source)
    at java.awt.Component.dispatchEvent(Unknown Source)
    at java.awt.LightweightDispatcher.retargetMouseEvent( Unknown Source)
    at java.awt.LightweightDispatcher.processMouseEvent(U nknown Source)
    at java.awt.LightweightDispatcher.dispatchEvent(Unkno wn Source)
    at java.awt.Container.dispatchEventImpl(Unknown Source)
    at java.awt.Window.dispatchEventImpl(Unknown Source)
    at java.awt.Component.dispatchEvent(Unknown Source)
    at java.awt.EventQueue.dispatchEvent(Unknown Source)
    at java.awt.EventDispatchThread.pumpOneEventForFilter s(Unknown Source)
    at java.awt.EventDispatchThread.pumpEventsForFilter(U nknown Source)
    at java.awt.EventDispatchThread.pumpEventsForHierarch y(Unknown Source)
    at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
    at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
    at java.awt.EventDispatchThread.run(Unknown Source)
    Caused by: 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.g etSQLException(Unknown Source)
    at org.apache.derby.client.am.SqlException.getSQLExce ption(Unknown Source)
    at org.apache.derby.jdbc.ClientDriver.connect(Unknown Source)
    at java.sql.DriverManager.getConnection(Unknown Source)
    at java.sql.DriverManager.getConnection(Unknown Source)
    at org.hibernate.connection.DriverManagerConnectionPr ovider.getConnection(DriverManagerConnectionProvid er.java:110)
    at org.hibernate.jdbc.ConnectionManager.openConnectio n(ConnectionManager.java:423)
    ... 42 more
    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>(Unknow n Source)
    at org.apache.derby.client.net.NetConnection.newAgent _(Unknown Source)
    at org.apache.derby.client.am.Connection.<init>(Unkno wn Source)
    at org.apache.derby.client.net.NetConnection.<init>(U nknown Source)
    at org.apache.derby.client.net.NetConnection40.<init> (Unknown Source)
    at org.apache.derby.client.net.ClientJDBCObjectFactor yImpl40.newNetConnection(Unknown Source)
    ... 47 more
    Caused by: java.net.ConnectException: Connection refused: connect
    at java.net.PlainSocketImpl.socketConnect(Native Method)
    at java.net.PlainSocketImpl.doConnect(Unknown Source)
    at java.net.PlainSocketImpl.connectToAddress(Unknown Source)
    at java.net.PlainSocketImpl.connect(Unknown Source)
    at java.net.SocksSocketImpl.connect(Unknown Source)
    at java.net.Socket.connect(Unknown Source)
    at java.net.Socket.connect(Unknown Source)
    at java.net.Socket.<init>(Unknown Source)
    at java.net.Socket.<init>(Unknown Source)
    at javax.net.DefaultSocketFactory.createSocket(Unknow n Source)
    at org.apache.derby.client.net.OpenSocketAction.run(U nknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    ... 53 more

  10. #10
    r035198x is offline Senior Member
    Join Date
    Aug 2009
    Posts
    2,388
    Rep Power
    7

    Default

    So you are getting a Connection refused problem.
    See if you can telnet to the DB port. If you cannot then you have a network connection problem.

Similar Threads

  1. File upload into database using Hibernate
    By liljejalil in forum JDBC
    Replies: 1
    Last Post: 02-28-2010, 03:11 AM
  2. Hibernate with multiple database
    By Marty in forum JDBC
    Replies: 3
    Last Post: 12-23-2008, 12:57 PM
  3. Database connectivity in Jave struts with Hibernate
    By sanjay_sharma77 in forum Advanced Java
    Replies: 1
    Last Post: 02-02-2008, 08:41 PM
  4. Replies: 0
    Last Post: 08-15-2007, 01:48 PM
  5. can hibernate work with Oracle 10g
    By javadev in forum JDBC
    Replies: 4
    Last Post: 07-08-2007, 08:47 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •