• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Problems with connectivity to the mysql-server

 
Ranch Hand
Posts: 116
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi community,

i have some very strange problems with the connectivity to my msql-server.

I have already installed the mysq-driver and eclipse shows me the correct Data-Source-Explorer as well.
But when I try to get a connection to the mysql-server via Java-Servlet, then I get the following error-message:

But when I try to get a connection with an averange java-class, which is in the "src"-folder, then it works.


I hope you can help me : )

Thank you very much!
 
Rancher
Posts: 4801
50
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You don't install the driver.
The driver has to be accessible at runtime on the classpath.

In the case of a Servlet, it depends on what server you are running on.  It is normally better to have the server (eg Tomcat) handle the connections.
 
Ralf Coby
Ranch Hand
Posts: 116
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi, and thank you fpr your help!

My Java-EE-Server is glassfish.
I dont have much knowledge about tomcat.

I think, I installed the mysq-driver in tje right way.

I have done the following steps below:


Window --> Preferences --> Data Management --> Connectivity --> Driver Definition --> [ADD] --> Vendor Filer [MySQL] --> select [MySQL JDBC Driver 5.1] --> tab[JAR List] --> [ADD JAR] --> Path to mysql-connector.jar

Even the Data-Source-Explorer finds my database with the correct tables... : (
 
Dave Tolls
Rancher
Posts: 4801
50
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
That's just telling Eclipse where the driver is so it can connect to the database so you can look at the tables.

it has no effect on your application.

I don't know how Glassfish works with this, but here is a MySQL(5.1) page on setting up the driver for it.
 
Ralf Coby
Ranch Hand
Posts: 116
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you so much for help!!!

It works!!!
 
Saloon Keeper
Posts: 27764
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The Eclipse Data Source Explorer is an Eclipse plugin. And, as Dave said, it has nothing to do with actually running the webapp. It's strictly a developer's tool.

Database Connection Pools (DataSources) are part of the J2EE spec and are the recommended way to obtain Connections for webapps to do database work. They allow efficient recycling of services in a multi-user environment.

Typically there's a control panel webapp for the webapp server that allows you to configure DataSources, and often it has the ability to import and install a driver JAR. Additionally, you can usually "brute-force" install a driver JAR into the webapp server. Which is how I usually do it in Tomcat. The exact location where the driver JAR must go depends on the webapp server, but can be found by reading the vendor's documentation. It's usually well-defined since datasources are a critical and popular service.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic