• 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

Java - Mysql connectivity

 
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
how do i connect to mysql database using java servlets . i want to use JdbcOdbcDriver..
i have written the following code which does not work .
try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
con=DriverManager.getConnection(url);
String command="INSERT INTO RegistrationInfo VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
PreparedStatement stmt=con.prepareStatement(command);
stmt.setString(1,loginId);
stmt.setString(2,password);
stmt.setLong(3,customerId);
stmt.setString(4,adminName);
stmt.setString(5,orgName);
stmt.setString(6,address1);
stmt.setString(7,address2);
stmt.setString(8,city);
stmt.setString(9,state);
stmt.setString(10,country);
stmt.setInt(11,zipcode);
stmt.setInt(12,phone1);
stmt.setInt(13,phone2);
stmt.setInt(14,fax);
stmt.setString(15,website);
stmt.executeUpdate();
}catch(Exception e) {
e.printStackTrace();
}
please help me .. ireally need it fast
 
Ranch Hand
Posts: 3244
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
amit
Are you getting an Exception? Which one?
What is the url you're using in your connection string?
Is the driver in you path?
If your using the JDBCODBC bridge then you alos need to have a DSN set up through myODBC, do you have my ODBC set up?
If you want to just connect with out using the DSN then you'll need a different driver. I've used the mm.mysql.jdbc-1.2c.
hope that helps, if not post some more info about your problem.
[ January 30, 2002: Message edited by: Dave Vick ]
 
Ranch Hand
Posts: 139
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,can I delete mm.mysql.jdbc-1.2c.bin in jdk1.X after I compiled the jdbc connection Servlet? I tried it and the Servlet seems continue to work too
 
reply
    Bookmark Topic Watch Topic
  • New Topic