Skip to Main Content

Java Database Connectivity (JDBC)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

JDBC Connection - Question regarding Class.forName usage

843859Mar 15 2008 — edited Mar 17 2008
Hi,

I'm connecting to MySql DB using the Code below (I copied from the internet)
I'm trying to understand what this code does exactly.

Can someone please explains what the line Class.forName does? I tried to read in the Java API but I still don't get it.

Thanks
            String userName = "root";
            String password = "root";
            String url = "jdbc:mysql://localhost:3306/test";
            Class.forName ("com.mysql.jdbc.Driver").newInstance();
            conn = DriverManager.getConnection (url, userName, password);
            System.out.println ("Database connection established");
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Apr 14 2008
Added on Mar 15 2008
2 comments
264 views