• 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
  • Tim Cooke
  • Devaka Cooray
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Carey Brown
  • Tim Holloway
Bartenders:
  • Martijn Verburg
  • Frits Walraven
  • Himai Minh

loading driver in JSP

 
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Following code is from jsp page

String driver = "org.gjt.mm.mysql.Driver";
Class.forName(driver).newInstance();

In this code, driver = "org.gjt.mm.mysql.Driver" ; specifies driver to be loaded for mysql database.
Question is, this driver has to be in the system before it is loaded. How does the driver get in the system ? Does it come with the import of "java.sql.* " package ?
Is this only driver available to connect to mysql from jsp ?
How to find the exact name of the driver to load it ? I mean I did not know the driver name to connect to mysql db I saw before this code. If I have to connect to DB2, how to find the name of the required driver ? How to make sure that its in the package ?

thanks
 
Ranch Hand
Posts: 152
Eclipse IDE Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Nirali,
You can also add This Driver to your project

for this to work you need to add a jar to your projects. lib directory inside WEB-INF.

mysql-connector-java-3.0.17-ga-bin.jar

you can google it and download it. or go to official Mysql site and download the jar from there.
And for the driver which you have specified their's some thing like MM.something.something driver i am not sure about the jar file name so if you want to proceed with your driver. kindly google it and download the jar and add it to your project's lib directory inside WEB-INF.
hope this helps
 
Ranch Hand
Posts: 2908
1
Spring Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

nirali shah wrote:
Question is, this driver has to be in the system before it is loaded.


Yes.

nirali shah wrote:
How does the driver get in the system ?


By putting driver's Jar file in classpath

nirali shah wrote:
Does it come with the import of "java.sql.* " package ?


No. 'java.sql' package provides the general class required to build JDBC code, also with 'Driver' class which has to be implemented by the Database Vendor in order to make JDBC driver.

nirali shah wrote:
Is this only driver available to connect to mysql from jsp ?


Interestingly, I never used/knew this driver, what I used for MySql is JConnector.

nirali shah wrote:
How to find the exact name of the driver to load it ? I mean I did not know the driver name to connect to mysql db I saw before this code. If I have to connect to DB2, how to find the name of the required driver ?


Consult the vendors page, asking about JDBC connection, If its MySQL, check there site,If its DB2, look at there site OR simple Consult Google
 
Fire me boy! Cool, soothing, shameless self promotion:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic