SHARE
TWEET

Untitled

a guest Jun 15th, 2017 54 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import java.sql.*;
  2.  
  3. public class dbfile
  4. {
  5.         public static void main(String[] args)
  6.         {
  7.                 DB db = new DB();
  8.                 Connection conn=db.dbConnect(
  9.                   "jdbc:mysql://nyctelecomm.com:3306/test", "brads",
  10. "andreasd");
  11.         }
  12.  
  13. }
  14.  
  15. class DB
  16. {
  17.         public DB() {}
  18.  
  19.         public Connection dbConnect(String db_connect_string,
  20.           String db_userid, String db_password)
  21.         {
  22.                 try
  23.                 {
  24.  
  25. Class.forName("com.mysql.jdbc.Driver").newInstance();
  26.                         Connection conn = DriverManager.getConnection(
  27.                           db_connect_string, db_userid, db_password);
  28.  
  29.                         System.out.println("connected");
  30.                         return conn;
  31.  
  32.                 }
  33.                 catch (Exception e)
  34.                 {
  35.                         e.printStackTrace();
  36.                         return null;
  37.                 }
  38.         }
  39. };
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top