Examples

Example: JDBC Connection example
Here is the code of program:

import java.sql.*;

public class MysqlConnect{

public static void main(String[] args) {

System.out.println("MySQL Connect Example.");
Connection conn = null;
String url = "jdbc:mysql://localhost:3306/";
String dbName = "jdbctutorial";
String driver = "com.mysql.jdbc.Driver";
String userName = "root";
String password = "root";
try {

Class.forName(driver).newInstance();
conn = DriverManager.getConnection(url+dbName,userName,password);
System.out.println("Connected to the database");
conn.close();
System.out.println("Disconnected from database");

} catch (Exception e) {

e.printStackTrace();

}

}

}

12 Trackbacks / Pingbacks

  1. app for pc
  2. app for pc
  3. free download for windows
  4. free download for windows 10
  5. app download for windows
  6. app download for pc
  7. free laptop games download
  8. apps for pc
  9. airbnb bali
  10. software development
  11. nill
  12. best male masturbation toy

Comments are closed.