Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.sql.*;
- public class SQLTest {
- public static void main(String[] args) {
- try {
- Class.forName("com.mysql.jdbc.Driver");
- Connection conn = DriverManager.getConnection("jdbc:mysql://localhost/test", "root", "");
- if (conn == null) {
- System.out.println("Conn null");
- } else {
- System.out.println("OK");
- try {
- conn.close();
- } catch (SQLException e) {
- e.printStackTrace();
- }
- }
- } catch(SQLException e) {
- System.out.println("SQLException: " e);
- e.printStackTrace();
- }catch(Exception e) {
- System.out.println("Exception: " e );
- e.printStackTrace();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement