java.sql.SQLException: Unable to connect to any hosts due to exception: java.net.ConnectException: Connection refused: connect

Oracle Community | 807595 | 1 decade ago
  1. 0

    cant install mysql driver

    Oracle Community | 1 decade ago | 807595
    java.sql.SQLException: Unable to connect to any hosts due to exception: java.net.ConnectException: Connection refused: connect
  2. 0

    Synopsis: When running SchemaExport from a Java program SQL exceptions are not caught in application catch clause. This means I am unable to detect programmatically if there is a failure in SchemaExport. I invoke SchemaExport with the following code: try { Configuration l_Configuration = new Configuration(); l_Configuration.configure(); SchemaExport l_SchemaExport = new SchemaExport( l_Configuration ); l_SchemaExport.create( true, true ); } catch ( Exception ex ) { System.out.println( "catch received" ); } In this case the MySQL database has not been started. Even though there is an exception it is never caught in the application catch. Here is the SchemaExport log: Mar 24, 2004 12:49:45 PM net.sf.hibernate.cfg.Environment <clinit> INFO: Hibernate 2.1.2 Mar 24, 2004 12:49:45 PM net.sf.hibernate.cfg.Environment <clinit> INFO: hibernate.properties not found Mar 24, 2004 12:49:45 PM net.sf.hibernate.cfg.Environment <clinit> INFO: using CGLIB reflection optimizer Mar 24, 2004 12:49:45 PM net.sf.hibernate.cfg.Configuration configure INFO: configuring from resource: /hibernate.cfg.xml Mar 24, 2004 12:49:45 PM net.sf.hibernate.cfg.Configuration getConfigurationInputStream INFO: Configuration resource: /hibernate.cfg.xml Mar 24, 2004 12:49:45 PM net.sf.hibernate.cfg.Configuration addResource INFO: Mapping resource: HibernateMapping.xml Mar 24, 2004 12:49:45 PM net.sf.hibernate.cfg.Binder bindRootClass INFO: Mapping class: com.digitalwake.datamanager.Root -> Root Mar 24, 2004 12:49:46 PM net.sf.hibernate.cfg.Binder bindRootClass INFO: Mapping class: com.digitalwake.datamanager.Organization -> Organization Mar 24, 2004 12:49:46 PM net.sf.hibernate.cfg.Binder bindRootClass INFO: Mapping class: com.digitalwake.datamanager.Attribute -> Attribute Mar 24, 2004 12:49:46 PM net.sf.hibernate.cfg.Binder bindRootClass INFO: Mapping class: com.digitalwake.datamanager.DataType -> DataType Mar 24, 2004 12:49:46 PM net.sf.hibernate.cfg.Binder bindSubclass INFO: Mapping subclass: com.digitalwake.datamanager.TextType -> DataType Mar 24, 2004 12:49:46 PM net.sf.hibernate.cfg.Binder bindSubclass INFO: Mapping subclass: com.digitalwake.datamanager.URLType -> DataType Mar 24, 2004 12:49:46 PM net.sf.hibernate.cfg.Binder bindSubclass INFO: Mapping subclass: com.digitalwake.datamanager.NumericType -> DataType Mar 24, 2004 12:49:46 PM net.sf.hibernate.cfg.Binder bindSubclass INFO: Mapping subclass: com.digitalwake.datamanager.TimeType -> DataType Mar 24, 2004 12:49:46 PM net.sf.hibernate.cfg.Configuration doConfigure INFO: Configured SessionFactory: null Mar 24, 2004 12:49:46 PM net.sf.hibernate.dialect.Dialect <init> INFO: Using dialect: net.sf.hibernate.dialect.MySQLDialect Mar 24, 2004 12:49:46 PM net.sf.hibernate.cfg.Configuration secondPassCompile INFO: processing one-to-many association mappings Mar 24, 2004 12:49:46 PM net.sf.hibernate.cfg.Binder bindCollectionSecondPass INFO: Mapping collection: com.digitalwake.datamanager.Root.Organizations -> Organization Mar 24, 2004 12:49:46 PM net.sf.hibernate.cfg.Binder bindCollectionSecondPass INFO: Mapping collection: com.digitalwake.datamanager.Root.DataTypes -> DataType Mar 24, 2004 12:49:46 PM net.sf.hibernate.cfg.Binder bindCollectionSecondPass INFO: Mapping collection: com.digitalwake.datamanager.Organization.Attributes -> Attribute Mar 24, 2004 12:49:46 PM net.sf.hibernate.cfg.Configuration secondPassCompile INFO: processing one-to-one association property references Mar 24, 2004 12:49:46 PM net.sf.hibernate.cfg.Configuration secondPassCompile INFO: processing foreign key constraints Mar 24, 2004 12:49:46 PM net.sf.hibernate.cfg.Configuration secondPassCompile INFO: processing one-to-many association mappings Mar 24, 2004 12:49:46 PM net.sf.hibernate.cfg.Configuration secondPassCompile INFO: processing one-to-one association property references Mar 24, 2004 12:49:46 PM net.sf.hibernate.cfg.Configuration secondPassCompile INFO: processing foreign key constraints Mar 24, 2004 12:49:46 PM net.sf.hibernate.tool.hbm2ddl.SchemaExport execute INFO: Running hbm2ddl schema export Mar 24, 2004 12:49:46 PM net.sf.hibernate.tool.hbm2ddl.SchemaExport execute INFO: exporting generated schema to database Mar 24, 2004 12:49:46 PM net.sf.hibernate.connection.DriverManagerConnectionProvider configure INFO: Using Hibernate built-in connection pool (not for production use!) Mar 24, 2004 12:49:46 PM net.sf.hibernate.connection.DriverManagerConnectionProvider configure INFO: Hibernate connection pool size: 20 Mar 24, 2004 12:49:46 PM net.sf.hibernate.connection.DriverManagerConnectionProvider configure INFO: using driver: com.mysql.jdbc.Driver at URL: jdbc:mysql:///DigitalWake Mar 24, 2004 12:49:46 PM net.sf.hibernate.connection.DriverManagerConnectionProvider configure INFO: connection properties: {} Mar 24, 2004 12:49:47 PM net.sf.hibernate.tool.hbm2ddl.SchemaExport execute SEVERE: schema export unsuccessful java.sql.SQLException: Unable to connect to any hosts due to exception: java.net.ConnectException: Connection refused: connect at com.mysql.jdbc.Connection.createNewIO(Connection.java:1690) at com.mysql.jdbc.Connection.<init>(Connection.java:427) at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:395) at java.sql.DriverManager.getConnection(DriverManager.java:512) at java.sql.DriverManager.getConnection(DriverManager.java:140) at net.sf.hibernate.connection.DriverManagerConnectionProvider.getConnection(DriverManagerConnectionProvider.java:95) at net.sf.hibernate.tool.hbm2ddl.SchemaExport.execute(SchemaExport.java:119) at net.sf.hibernate.tool.hbm2ddl.SchemaExport.create(SchemaExport.java:84) at com.digitalwake.datamanager.test.createSchemaTest(test.java:48) at com.digitalwake.datamanager.test.main(test.java:37)

    Hibernate JIRA | 1 decade ago | Bruce Scott
    java.sql.SQLException: Unable to connect to any hosts due to exception: java.net.ConnectException: Connection refused: connect
  3. 0

    Synopsis: When running SchemaExport from a Java program SQL exceptions are not caught in application catch clause. This means I am unable to detect programmatically if there is a failure in SchemaExport. I invoke SchemaExport with the following code: try { Configuration l_Configuration = new Configuration(); l_Configuration.configure(); SchemaExport l_SchemaExport = new SchemaExport( l_Configuration ); l_SchemaExport.create( true, true ); } catch ( Exception ex ) { System.out.println( "catch received" ); } In this case the MySQL database has not been started. Even though there is an exception it is never caught in the application catch. Here is the SchemaExport log: Mar 24, 2004 12:49:45 PM net.sf.hibernate.cfg.Environment <clinit> INFO: Hibernate 2.1.2 Mar 24, 2004 12:49:45 PM net.sf.hibernate.cfg.Environment <clinit> INFO: hibernate.properties not found Mar 24, 2004 12:49:45 PM net.sf.hibernate.cfg.Environment <clinit> INFO: using CGLIB reflection optimizer Mar 24, 2004 12:49:45 PM net.sf.hibernate.cfg.Configuration configure INFO: configuring from resource: /hibernate.cfg.xml Mar 24, 2004 12:49:45 PM net.sf.hibernate.cfg.Configuration getConfigurationInputStream INFO: Configuration resource: /hibernate.cfg.xml Mar 24, 2004 12:49:45 PM net.sf.hibernate.cfg.Configuration addResource INFO: Mapping resource: HibernateMapping.xml Mar 24, 2004 12:49:45 PM net.sf.hibernate.cfg.Binder bindRootClass INFO: Mapping class: com.digitalwake.datamanager.Root -> Root Mar 24, 2004 12:49:46 PM net.sf.hibernate.cfg.Binder bindRootClass INFO: Mapping class: com.digitalwake.datamanager.Organization -> Organization Mar 24, 2004 12:49:46 PM net.sf.hibernate.cfg.Binder bindRootClass INFO: Mapping class: com.digitalwake.datamanager.Attribute -> Attribute Mar 24, 2004 12:49:46 PM net.sf.hibernate.cfg.Binder bindRootClass INFO: Mapping class: com.digitalwake.datamanager.DataType -> DataType Mar 24, 2004 12:49:46 PM net.sf.hibernate.cfg.Binder bindSubclass INFO: Mapping subclass: com.digitalwake.datamanager.TextType -> DataType Mar 24, 2004 12:49:46 PM net.sf.hibernate.cfg.Binder bindSubclass INFO: Mapping subclass: com.digitalwake.datamanager.URLType -> DataType Mar 24, 2004 12:49:46 PM net.sf.hibernate.cfg.Binder bindSubclass INFO: Mapping subclass: com.digitalwake.datamanager.NumericType -> DataType Mar 24, 2004 12:49:46 PM net.sf.hibernate.cfg.Binder bindSubclass INFO: Mapping subclass: com.digitalwake.datamanager.TimeType -> DataType Mar 24, 2004 12:49:46 PM net.sf.hibernate.cfg.Configuration doConfigure INFO: Configured SessionFactory: null Mar 24, 2004 12:49:46 PM net.sf.hibernate.dialect.Dialect <init> INFO: Using dialect: net.sf.hibernate.dialect.MySQLDialect Mar 24, 2004 12:49:46 PM net.sf.hibernate.cfg.Configuration secondPassCompile INFO: processing one-to-many association mappings Mar 24, 2004 12:49:46 PM net.sf.hibernate.cfg.Binder bindCollectionSecondPass INFO: Mapping collection: com.digitalwake.datamanager.Root.Organizations -> Organization Mar 24, 2004 12:49:46 PM net.sf.hibernate.cfg.Binder bindCollectionSecondPass INFO: Mapping collection: com.digitalwake.datamanager.Root.DataTypes -> DataType Mar 24, 2004 12:49:46 PM net.sf.hibernate.cfg.Binder bindCollectionSecondPass INFO: Mapping collection: com.digitalwake.datamanager.Organization.Attributes -> Attribute Mar 24, 2004 12:49:46 PM net.sf.hibernate.cfg.Configuration secondPassCompile INFO: processing one-to-one association property references Mar 24, 2004 12:49:46 PM net.sf.hibernate.cfg.Configuration secondPassCompile INFO: processing foreign key constraints Mar 24, 2004 12:49:46 PM net.sf.hibernate.cfg.Configuration secondPassCompile INFO: processing one-to-many association mappings Mar 24, 2004 12:49:46 PM net.sf.hibernate.cfg.Configuration secondPassCompile INFO: processing one-to-one association property references Mar 24, 2004 12:49:46 PM net.sf.hibernate.cfg.Configuration secondPassCompile INFO: processing foreign key constraints Mar 24, 2004 12:49:46 PM net.sf.hibernate.tool.hbm2ddl.SchemaExport execute INFO: Running hbm2ddl schema export Mar 24, 2004 12:49:46 PM net.sf.hibernate.tool.hbm2ddl.SchemaExport execute INFO: exporting generated schema to database Mar 24, 2004 12:49:46 PM net.sf.hibernate.connection.DriverManagerConnectionProvider configure INFO: Using Hibernate built-in connection pool (not for production use!) Mar 24, 2004 12:49:46 PM net.sf.hibernate.connection.DriverManagerConnectionProvider configure INFO: Hibernate connection pool size: 20 Mar 24, 2004 12:49:46 PM net.sf.hibernate.connection.DriverManagerConnectionProvider configure INFO: using driver: com.mysql.jdbc.Driver at URL: jdbc:mysql:///DigitalWake Mar 24, 2004 12:49:46 PM net.sf.hibernate.connection.DriverManagerConnectionProvider configure INFO: connection properties: {} Mar 24, 2004 12:49:47 PM net.sf.hibernate.tool.hbm2ddl.SchemaExport execute SEVERE: schema export unsuccessful java.sql.SQLException: Unable to connect to any hosts due to exception: java.net.ConnectException: Connection refused: connect at com.mysql.jdbc.Connection.createNewIO(Connection.java:1690) at com.mysql.jdbc.Connection.<init>(Connection.java:427) at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:395) at java.sql.DriverManager.getConnection(DriverManager.java:512) at java.sql.DriverManager.getConnection(DriverManager.java:140) at net.sf.hibernate.connection.DriverManagerConnectionProvider.getConnection(DriverManagerConnectionProvider.java:95) at net.sf.hibernate.tool.hbm2ddl.SchemaExport.execute(SchemaExport.java:119) at net.sf.hibernate.tool.hbm2ddl.SchemaExport.create(SchemaExport.java:84) at com.digitalwake.datamanager.test.createSchemaTest(test.java:48) at com.digitalwake.datamanager.test.main(test.java:37)

    Hibernate JIRA | 1 decade ago | Bruce Scott
    java.sql.SQLException: Unable to connect to any hosts due to exception: java.net.ConnectException: Connection refused: connect
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

  5. 0

    JDBC:Connection Issue When Run program

    Stack Overflow | 1 year ago | hamel123
    java.sql.SQLException: Must specify port after ':' in connection string
  6. 0

    Android studio JDBC MySQL

    Stack Overflow | 3 months ago | scarface
    java.sql.SQLException: java.lang.VerifyError: Verifier rejected class com.mysql.jdbc.CharsetMapping: void com.mysql.jdbc.CharsetMapping.<clinit>() failed to verify: void com.mysql.jdbc.CharsetMapping.<clinit>(): [0x4287] Invalid reg type for array index (Precise Reference: com.mysql.jdbc.MysqlCharset[]) (declaration of 'com.mysql.jdbc.CharsetMapping' appears in /data/app/allanko.quizzerappandroid-1/base.apk)

  1. linxiaolong 2 times, last 6 days ago
7 unregistered visitors
Not finding the right solution?
Take a tour to get the most out of Samebug.

Tired of useless tips?

Automated exception search integrated into your IDE

Root Cause Analysis

  1. java.sql.SQLException

    Unable to connect to any hosts due to exception: java.net.ConnectException: Connection refused: connect

    at com.mysql.jdbc.Connection.createNewIO()
  2. MySQL jdbc
    NonRegisteringDriver.connect
    1. com.mysql.jdbc.Connection.createNewIO(Connection.java:1797)
    2. com.mysql.jdbc.Connection.<init>(Connection.java:562)
    3. com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:361)
    3 frames
  3. Java RT
    DriverManager.getConnection
    1. java.sql.DriverManager.getConnection(DriverManager.java:512)
    2. java.sql.DriverManager.getConnection(DriverManager.java:193)
    2 frames
  4. Unknown
    bd.main
    1. bd.main(bd.java:12)
    1 frame