JDBC Simple Connection
import java.sql.Connection; import java.sql.DriverManager; import java.sql.SQLException; public class SimpleConnection { static public void main(String args[]) { Connection connection = null; if (args.length != 4) { System.out.println("Syntax: java SimpleConnection " + "DRIVER URL UID PASSWORD"); return; } try { Class.forName(args[0]).newInstance(); } catch (Exception e) { e.printStackTrace(); return; } try { connection = DriverManager.getConnection(args[1], args[2], args[3]); System.out.println("Connection successful!"); } catch (SQLException e) { e.printStackTrace(); } finally { if (connection != null) { try { connection.close(); } catch (SQLException e) { e.printStackTrace(); } } } } }