import java.sql.Connection; import java.util.Properties; import com.mysql.jdbc.Driver; public class MysqlTest { public static void main(String[] args) throws Exception { Driver driver = new Driver(); Properties props = new Properties(); props.put("user", "foo"); props.put("password", "bar"); try { Connection conn = driver.connect( "jdbc:mysql://172.30.5.91/test?connectTimeout=2000", props); } catch (Throwable e) { System.out.println("Got " + e.getClass().getName() + " telling " + e.getMessage() + "\n------\n"); } try { Connection conn = driver.connect("jdbc:mysql://172.30.5.91/test", props); } catch (Throwable e) { System.out.println("Got " + e.getClass().getName() + " telling " + e.getMessage()); } } }