Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static void main(String[] args){
- // note: the application running on localhost:1433 is ACTUALLY
- // an MS SQL Server instance!
- String jdbcUrl = "jdbc:mysql://localhost:1433/my-db";
- // enable JDBC Driver Manager logging
- DriverManager.setLogWriter(new PrintWriter(System.err));
- // set a timeout of 5 seconds for connecting (which is blissfully ignored!)
- DriverManager.setLoginTimeout(5);
- // open the connection (which should fail, but freezes instead)
- try (Connection c = DriverManager.getConnection(jdbcUrl)){
- System.out.println("This should never be reached due to wrong JDBC URL.");
- }catch(Exception e){
- System.out.println("This is expected (but never printed).");
- }
- System.out.println("This is never printed either.");
- }
Add Comment
Please, Sign In to add comment