1

I am trying to connect to my MySQL database.I believe this is the correct format, however when I execute the code I get a stranger error. Any help is appreciated.

con = (Connection) DriverManager.getConnection("jdbc:mysql://bondsolutionsnjcom.fatcowmysql.csom:3306;account_information", "aiforfrg", "****");

SEVERE: null
com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: Cannot load connection class because of underlying exception: 'java.lang.NumberFormatException: For input string: "3306;account_information"'.
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
    at com.mysql.jdbc.Util.handleNewInstance(Util.java:411)
    at com.mysql.jdbc.Util.getInstance(Util.java:386)
    at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1014)
    at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:988)
    at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:974)
    at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:919)
    at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:326)
    at java.sql.DriverManager.getConnection(DriverManager.java:571)
    at java.sql.DriverManager.getConnection(DriverManager.java:215)
    at frglauncher.Main.menuLoginActionPerformed(Main.java:283)
    at frglauncher.Main.access$500(Main.java:50)
    at frglauncher.Main$4.actionPerformed(Main.java:189)
    at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:2018)
    at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2341)
    at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:402)
    at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:259)
    at javax.swing.AbstractButton.doClick(AbstractButton.java:376)
    at javax.swing.plaf.basic.BasicMenuItemUI.doClick(BasicMenuItemUI.java:833)
    at javax.swing.plaf.basic.BasicMenuItemUI$Handler.mouseReleased(BasicMenuItemUI.java:877)
    at java.awt.Component.processMouseEvent(Component.java:6505)
    at javax.swing.JComponent.processMouseEvent(JComponent.java:3321)
    at java.awt.Component.processEvent(Component.java:6270)
    at java.awt.Container.processEvent(Container.java:2229)
    at java.awt.Component.dispatchEventImpl(Component.java:4861)
    at java.awt.Container.dispatchEventImpl(Container.java:2287)
    at java.awt.Component.dispatchEvent(Component.java:4687)
    at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4832)
    at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4492)
    at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4422)
    at java.awt.Container.dispatchEventImpl(Container.java:2273)
    at java.awt.Window.dispatchEventImpl(Window.java:2719)
$2a$99$JsJZPZenlSLpGa8H62R25O5L4q6a0qLzSOpSpK7ZIONwhTTLmMHNm
    at java.awt.Component.dispatchEvent(Component.java:4687)
    at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:735)
    at java.awt.EventQueue.access$200(EventQueue.java:103)
    at java.awt.EventQueue$3.run(EventQueue.java:694)
    at java.awt.EventQueue$3.run(EventQueue.java:692)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:87)
    at java.awt.EventQueue$4.run(EventQueue.java:708)
    at java.awt.EventQueue$4.run(EventQueue.java:706)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
    at java.awt.EventQueue.dispatchEvent(EventQueue.java:705)
https://bondsolutionsnjcom.fatcow.com/frg/scripts/checklogin.php?username=kmccmk9&password=$2a$99$JsJZPZenlSLpGa8H62R25O5L4q6a0qLzSOpSpK7ZIONwhTTLmMHNm
    at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:242)
    at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:161)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:150)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:146)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:138)
    at java.awt.EventDispatchThread.run(EventDispatchThread.java:91)
Caused by: java.lang.NumberFormatException: For input string: "3306;account_information"
    at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)
    at java.lang.Integer.parseInt(Integer.java:492)
    at java.lang.Integer.parseInt(Integer.java:527)
    at com.mysql.jdbc.NonRegisteringDriver.port(NonRegisteringDriver.java:849)
    at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:317)
    ... 43 more

This was fixed using a / instead of the ; in the url string. However I am now presented with the following error

SEVERE: null
com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure

The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
    at com.mysql.jdbc.Util.handleNewInstance(Util.java:411)
    at com.mysql.jdbc.SQLError.createCommunicationsException(SQLError.java:1117)
    at com.mysql.jdbc.MysqlIO.<init>(MysqlIO.java:355)
    at com.mysql.jdbc.ConnectionImpl.coreConnect(ConnectionImpl.java:2461)
    at com.mysql.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:2498)
    at com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2283)
    at com.mysql.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:822)
    at com.mysql.jdbc.JDBC4Connection.<init>(JDBC4Connection.java:47)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
    at com.mysql.jdbc.Util.handleNewInstance(Util.java:411)
    at com.mysql.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:404)
    at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:317)
    at java.sql.DriverManager.getConnection(DriverManager.java:571)
    at java.sql.DriverManager.getConnection(DriverManager.java:215)
    at frglauncher.Main.menuLoginActionPerformed(Main.java:283)
    at frglauncher.Main.access$500(Main.java:50)
    at frglauncher.Main$4.actionPerformed(Main.java:189)
    at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:2018)
    at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2341)
    at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:402)
    at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:259)
    at javax.swing.AbstractButton.doClick(AbstractButton.java:376)
    at javax.swing.plaf.basic.BasicMenuItemUI.doClick(BasicMenuItemUI.java:833)
    at javax.swing.plaf.basic.BasicMenuItemUI$Handler.mouseReleased(BasicMenuItemUI.java:877)
    at java.awt.Component.processMouseEvent(Component.java:6505)
    at javax.swing.JComponent.processMouseEvent(JComponent.java:3321)
    at java.awt.Component.processEvent(Component.java:6270)
    at java.awt.Container.processEvent(Container.java:2229)
    at java.awt.Component.dispatchEventImpl(Component.java:4861)
    at java.awt.Container.dispatchEventImpl(Container.java:2287)
    at java.awt.Component.dispatchEvent(Component.java:4687)
    at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4832)
    at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4492)
    at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4422)
    at java.awt.Container.dispatchEventImpl(Container.java:2273)
    at java.awt.Window.dispatchEventImpl(Window.java:2719)
    at java.awt.Component.dispatchEvent(Component.java:4687)
    at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:735)
    at java.awt.EventQueue.access$200(EventQueue.java:103)
    at java.awt.EventQueue$3.run(EventQueue.java:694)
    at java.awt.EventQueue$3.run(EventQueue.java:692)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:87)
    at java.awt.EventQueue$4.run(EventQueue.java:708)
    at java.awt.EventQueue$4.run(EventQueue.java:706)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
    at java.awt.EventQueue.dispatchEvent(EventQueue.java:705)
    at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:242)
    at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:161)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:150)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:146)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:138)
    at java.awt.EventDispatchThread.run(EventDispatchThread.java:91)
Caused by: java.net.UnknownHostException: bondsolutionsnjcom.fatcowmysql.csom
    at java.net.Inet6AddressImpl.lookupAllHostAddr(Native Method)
    at java.net.InetAddress$1.lookupAllHostAddr(InetAddress.java:894)
    at java.net.InetAddress.getAddressesFromNameService(InetAddress.java:1286)
    at java.net.InetAddress.getAllByName0(InetAddress.java:1239)
    at java.net.InetAddress.getAllByName(InetAddress.java:1155)
    at java.net.InetAddress.getAllByName(InetAddress.java:1091)
    at com.mysql.jdbc.StandardSocketFactory.connect(StandardSocketFactory.java:249)
    at com.mysql.jdbc.MysqlIO.<init>(MysqlIO.java:305)
Kyle
  • 2,339
  • 10
  • 33
  • 67

3 Answers3

2

Try this.

con = (Connection) DriverManager.getConnection("jdbc:mysql://bondsolutionsnjcom.fatcowmysql.csom:3306/account_information", "aiforfrg", "****");
Bishan
  • 15,211
  • 52
  • 164
  • 258
  • Thanks for the response, I now have a new error though. Please see the edited post. – Kyle Nov 24 '13 at 05:21
  • I did, but as I found out, the problem is that my db host doesn't allow java jdbc connections. Is there a workaround I'm thinking of java php bridge? – Kyle Nov 24 '13 at 21:00
  • what is the exception you are getting now ? still getting `UnknownHostException` or any other exception ? – Bishan Nov 25 '13 at 03:18
  • It was a driver exception dealing jdbc. I've tried to change my code so many times I"m not sure of the original code tpo produce error. But the new error basically meant that my db server was rejecting the jdbc request. It looks as though my only options are php and perl. – Kyle Nov 26 '13 at 00:02
  • Could you please update your question with current exception you are getting ? – Bishan Nov 26 '13 at 02:55
2

Try this

"jdbc:mysql://bondsolutionsnjcom.fatcowmysql.csom:3306/account_information"

instead of this

"jdbc:mysql://bondsolutionsnjcom.fatcowmysql.csom:3306;account_information"
Harsh Singal
  • 377
  • 1
  • 7
  • Thanks for the response, I now have a new error though. Please see the edited post. – Kyle Nov 24 '13 at 05:20
  • EDIT: I tried to ping the link bondsolutionsnjcom.fatcowmysql.csom and in reply I am getting Request Timeout. Are you sure the host address is correct? Check these links please: [link]http://stackoverflow.com/questions/2121829/mysql-jdbc-communications-link-failure [link]http://stackoverflow.com/questions/6865538/solving-a-communications-link-failure-with-jdbc-and-mysql – Harsh Singal Nov 24 '13 at 05:28
  • Ya it should be, I use the same code in my php file. However, I did notice that I have csom for some reason. Although even with the change to com, it has the same error. – Kyle Nov 24 '13 at 05:34
  • Can you try to use the following command on command prompt/terminal: `ping bondsolutionsnjcom.fatcowmysql.csom` OR `ping 202.136.40.61` (IP address when I used ping command on my end) and check what are you getting? – Harsh Singal Nov 24 '13 at 05:39
  • Request time out. Yet, my php file still works fine. – Kyle Nov 24 '13 at 05:45
  • Please check this: [http://jaykhimani.blogspot.com.au/2010/06/connecting-mysql-51-database-remotely.html] – Harsh Singal Nov 24 '13 at 05:49
  • Okay so it seems the problem is that my host provider claims to not support Java. Is there any kind of workaround for this? – Kyle Nov 24 '13 at 06:04
  • I am not sure how you can be helped here. May be you have to do some research. I found the following link from stackoverflow. Hope it helps: http://stackoverflow.com/questions/5158792/java-web-hosting – Harsh Singal Nov 24 '13 at 11:32
0

You have problem in the URL of the server... its should be like follow "jdbc:mysql://localhost:3306/db_name" where u can replace 'localhost' with the preferred server name if you are using remote server and port number should be accordingly changed.