This week's book giveaway is in the Jython/Python forum.
We're giving away four copies of Hands On Software Engineering with Python and have Brian Allbey on-line!
See this thread for details.
Win a copy of Hands On Software Engineering with Python this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Bear Bibeault
  • Knute Snortum
  • Liutauras Vilda
Sheriffs:
  • Tim Cooke
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Tim Moores
  • Frits Walraven
  • Ron McLeod
  • Ganesh Patekar
  • salvin francis
Bartenders:
  • Tim Holloway
  • Carey Brown
  • Stephan van Hulst

How do I connect multiple Swing applications to database?  RSS feed

 
Greenhorn
Posts: 3
C++ Java Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So i'm creating a distributed swing application which access remote database. How to connect to that database from swing application?

I have implemented simple jdbc connection. will providing ipaddress and port no of server in database URL do the work?

Or i have to use some other technique like RMI and servlet??
 
Saloon Keeper
Posts: 5128
135
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
JDBC will work fine, assuming there is no firewall or anything else in between that prevents a connection.
 
Pritam Parab
Greenhorn
Posts: 3
C++ Java Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Tim, thank you for replying

I'm getting following exception:

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(Unknown Source)
       at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
       at java.lang.reflect.Constructor.newInstance(Unknown Source)
       at com.mysql.jdbc.Util.handleNewInstance(Util.java:425)
       at com.mysql.jdbc.SQLError.createCommunicationsException(SQLError.java:990)
       at com.mysql.jdbc.MysqlIO.<init>(MysqlIO.java:341)
       at com.mysql.jdbc.ConnectionImpl.coreConnect(ConnectionImpl.java:2186)
       at com.mysql.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:2219)
       at com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2014)
       at com.mysql.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:776)
       at com.mysql.jdbc.JDBC4Connection.<init>(JDBC4Connection.java:47)
       at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
       at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
       at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
       at java.lang.reflect.Constructor.newInstance(Unknown Source)
       at com.mysql.jdbc.Util.handleNewInstance(Util.java:425)
       at com.mysql.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:386)
       at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:330)
       at java.sql.DriverManager.getConnection(Unknown Source)
       at java.sql.DriverManager.getConnection(Unknown Source)
       at demo.main(demo.java:18)
Caused by: java.net.ConnectException: Connection timed out: connect
       at java.net.DualStackPlainSocketImpl.connect0(Native Method)
       at java.net.DualStackPlainSocketImpl.socketConnect(Unknown Source)
       at java.net.AbstractPlainSocketImpl.doConnect(Unknown Source)
       at java.net.AbstractPlainSocketImpl.connectToAddress(Unknown Source)
       at java.net.AbstractPlainSocketImpl.connect(Unknown Source)
       at java.net.PlainSocketImpl.connect(Unknown Source)
       at java.net.SocksSocketImpl.connect(Unknown Source)
       at java.net.Socket.connect(Unknown Source)
       at com.mysql.jdbc.StandardSocketFactory.connect(StandardSocketFactory.java:211)
       at com.mysql.jdbc.MysqlIO.<init>(MysqlIO.java:300)
       ... 15 more
com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure
 
Rancher
Posts: 3796
40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Before trying to connect using Java, try and connect using either the shell or the workbench.
No point trying to get JDBC to work if the computer can't talk to the instance in the first place.
 
Oh the stink of it! Smell my tiny ad!
Programmatically Create PDF Using Free Spire.PDF with Java
https://coderanch.com/wiki/703735/Programmatically-Create-PDF-Free-Spire
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!