Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import com.mysql.jdbc.*;
- import java.sql.*;
- public class dbfile
- {
- public static void main(String[] args)
- {
- DB db = new DB();
- Connection conn=db.dbConnect(
- "jdbc:mysql://nyctelecomm.com:3306/test", "brads",
- "andreasd");
- }
- }
- class DB
- {
- public DB() {}
- public Connection dbConnect(String db_connect_string,
- String db_userid, String db_password)
- {
- try
- {
- Class.forName("com.mysql.jdbc.Driver").newInstance();
- Connection conn = DriverManager.getConnection(
- db_connect_string, db_userid, db_password);
- System.out.println("connected");
- return conn;
- }
- catch (Exception e)
- {
- e.printStackTrace();
- return null;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement