dcsimg
My Sql JDBC connectivity
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   bindu_madhavi
Posted On:   Tuesday, February 3, 2004 04:12 AM

hi can anybody help
I Have Installed MySQL server In system.How can I connect MySQL database using JDBC connectivity.
The environment that Iam using is tomcat4.1 and j2sdk1.4.1_01 with windows2000

Re: My Sql JDBC connectivity

Posted By:   Anonymous  
Posted On:   Tuesday, February 10, 2004 01:14 AM


Look at the sample Code:
------------------------

Class.forName("org.gjt.mm.mysql.Driver");
Connection con=DriverManager.getConnection("jdbc:mysql://localhost:3306/[db_name]","","");
Statement st=con.createStatement();
String query="select * from [table_name]";
rs=st.executeQuery(query);

but make sure to put mysql-connector-java-3.1.0-alpha-bin.jar file in classpath. (You may get this jar file from net.)

hope this helps..
About | Sitemap | Contact