aspose file tools*
The moose likes JDBC and the fly likes Java - Mysql connectivity Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Java - Mysql connectivity " Watch "Java - Mysql connectivity " New topic
Author

Java - Mysql connectivity

Amit Goel
Ranch Hand

Joined: Dec 07, 2000
Posts: 50
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


Amit<br /> <br />The Less I have, The more I gain..Off the Beaten Path, I Reign.
Dave Vick
Ranch Hand

Joined: May 10, 2001
Posts: 3244
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 ]

Dave
Ken Shamrock
Ranch Hand

Joined: Jan 23, 2002
Posts: 139
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


Thanks everyone who helped me
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Java - Mysql connectivity