Advertisement
Guest User

Untitled

a guest
Aug 2nd, 2017
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.64 KB | None | 0 0
  1. import java.sql.*;
  2.  
  3. public class SQLTest {
  4.  
  5. public static void main(String[] args) {
  6. try {
  7. Class.forName("com.mysql.jdbc.Driver");
  8.  
  9. Connection conn = DriverManager.getConnection("jdbc:mysql://localhost/test", "root", "");
  10. if (conn == null) {
  11. System.out.println("Conn null");
  12. } else {
  13. System.out.println("OK");
  14. try {
  15. conn.close();
  16. } catch (SQLException e) {
  17. e.printStackTrace();
  18. }
  19. }
  20. } catch(SQLException e) {
  21. System.out.println("SQLException: " e);
  22. e.printStackTrace();
  23. }catch(Exception e) {
  24. System.out.println("Exception: " e );
  25. e.printStackTrace();
  26. }
  27. }
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement