Jdbc tutorial, jdbc connection, java resultset, java, jdbc driver, java database connectivity, jdbc source code, tutorial, programming,JDBC driver, JDBC example, Jdbc examples!
Sycorax - complete tutorials
Programming Tutorials
" Java provides the industry - software companies and customer alike , an opportunity to create a true open computing environment where software is portable,
and customers benefit from increase competition. "
Java and the Future
December 1, 2008-LEJB 3.1: EJB New and Improved!
The EJB 3.0 specification was a huge improvement from what you were used to in the early versions of EJB. Available as an early draft, EJB 3.1 has many more features and is even easier to use.
December 1, 2008-Should Java Assert that Network I/O Can't Occur on the UI Thread?
Doing network I/O on the user interface (UI) thread is bad. Most developers know that and can tell you why; unfortunately, it's still done.
Register now to recieve special alert and latest technology news!
Test JDBC Driver Installation & Connection
Download the MYSQL jdbc driver from http://dev.mysql.com/downloads/connector/j/5.1.html
Write the program
Source code of the program: JDBCDriverInfo.java
import java.sql.Connection;
import java.sql.DatabaseMetaData;
import java.sql.DriverManager;
import java.sql.SQLException;
public class JDBCDriverInfo {
static String userid="root", password = "mysql";
static String url = "jdbc:mysql://localhost:3306/";
static String db = "sycoraxjdbctutorial";
static Connection con = null;
public static void main(String[] args) throws Exception {
Connection con = getJDBCConnection();
if(con!= null){
System.out.println("Got Connection.");
DatabaseMetaData meta = con.getMetaData();
System.out.println("Driver Name : "+meta.getDriverName());
System.out.println("Driver Version :"+meta.getDriverVersion());
}else{
System.out.println("Could not Get Connection");
}
}
public static Connection getJDBCConnection(){
try {
Class.forName("com.mysql.jdbc.Driver");
} catch(java.lang.ClassNotFoundException e) {
System.err.print("ClassNotFoundException: ");
System.err.println(e.getMessage());
}
try {
con = DriverManager.getConnection(url+db, userid, password);
} catch(SQLException ex) {
System.err.println("SQLException: " + ex.getMessage());
}
return con;
}
}


