Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within JDBC and Relational Databases
Search Coderanch
Advance search
Google search
Register / Login
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
Forum:
JDBC and Relational Databases
ClassNotFoundException Mysql
Adil Sadiq
Greenhorn
Posts: 1
posted 10 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
import java.sql.*; class MysqlCon{ public static void main(String args[]){ try{ Class.forName("com.mysql.jdbc.Driver"); Connection con=DriverManager.getConnection("jdbc:mysql://localhost:3306/test","root","root"); //here test is the database name, root is the username and root is the password Statement stmt=con.createStatement(); ResultSet rs=stmt.executeQuery("select * from person"); while(rs.next()) System.out.println(rs.getInt(1)+" "+rs.getString(2)+" "+rs.getString(3)); con.close(); }catch(Exception e){ //System.out.println(e); e.printStackTrace(); } } }
exception.png
i have added mysql-connector.jar in jre/lib/ext
Ulf Dittmer
Rancher
Posts: 43081
77
posted 10 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
You need to put the MySQL
JDBC
driver jar file in the classpath.
They worship nothing. They say it's because nothing lasts forever. Like this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
ClassNotFoundException with ResourceBundle
dbMeta.getSchemas() seems not to work
Database Issue when displaying data.
JDBC using ResourceBundle Class Problem
how to improve my program code ?
More...