Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.sql.Connection;
- import java.sql.DriverManager;
- import java.sql.SQLException;
- public class JDBCTest {
- public static void main(String[] args) {
- String url = null ;
- String driver = null ;
- Connection conn = null ;
- String db = null ;
- try
- {
- url = "jdbc:mysql://VPREMOTELOGGER:3306/";
- db = "logger";
- driver = "com.mysql.jdbc.Driver";
- Class.forName(driver);
- conn = DriverManager.getConnection(url+db, "remoteUsr", "changme");
- System.out.println("Reached end without exception");
- }
- catch(ClassNotFoundException classNotFound)
- {
- System.out.println("Class Not Found");
- classNotFound.printStackTrace();
- }
- catch(SQLException sql)
- {
- System.out.println("SQL Exception");
- sql.printStackTrace();
- }
- finally
- {
- if (conn != null)
- try {
- conn.close();
- } catch (SQLException e) {
- System.out.println("Connection not closed properly");
- e.printStackTrace();
- }
- }
- }
- }
Add Comment
Please, Sign In to add comment