Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / June 2007

Tip: Looking for answers? Try searching our database.

No Suitable Driver at dataSource.getConnection();

Thread view: 
alomrani@gmail.com - 11 Jun 2007 11:03 GMT
Hi all ,,

I had my application to connect to the database in a classical way
i.e. not a pooled connection. The method was as fellows

 private void connect(){
   try
   {
     Class.forName("com.mysql.jdbc.Driver");
     con = DriverManager.getConnection(URL,"root","root");
     stmt = con.createStatement();
     isConnected=true;
   }
   catch(Exception e)
   {
     System.out.println(e);
   }
 }

Now I want to change that function into the following :

private void pooledConnection() throws Exception {
       Class.forName("com.mysql.jdbc.Driver");
       String connectURI    =   "jdbc:mysql://127.0.0.1:3306/
attendance_test";
       DataSource dataSource = setupDataSource(connectURI);
       con = dataSource.getConnection();
       stmt = con.createStatement();
      }

      public static DataSource setupDataSource(String connectURI) {
       org.apache.commons.pool.ObjectPool connectionPool = new
GenericObjectPool(null);
       ConnectionFactory connectionFactory = new
DriverManagerConnectionFactory(connectURI,null);
       PoolableConnectionFactory poolableConnectionFactory = new
PoolableConnectionFactory(connectionFactory,connectionPool,null,null,false,true);
       PoolingDataSource dataSource = new
PoolingDataSource(connectionPool);
       return dataSource;
   }

I get an Error of a Suitable driver not found At the line that trues
to connect to the datasource

con = dataSource.getConnection();

The thing is I am 100% sure that the classpath is set properly of the
driver. Thats why the prioir method works .. But how come this doesnt
work.

I appreciate all your help guys.
richardsosborn@gmail.com - 18 Jun 2007 21:24 GMT
On Jun 11, 6:03 am, alomr...@gmail.com wrote:
> Hi all ,,
>
[quoted text clipped - 48 lines]
>
> I appreciate all your help guys.

this could mean a variety of things.  your URL could be wrong.
you need to verify the syntax with your driver manufacturer.
the database could be unavailable over the network.  you password
could be wrong, etc.  try connecting to that database, using a
database client, from your box.


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.