Advertisement
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 Connect {
- String userName;
- String password;
- String dbms;
- String portNumber;
- String serverName;
- public Connect(String userName, String password, String dbms, String portNumber, String serverName) {
- super();
- this.userName = userName;
- this.password = password;
- this.dbms = dbms;
- this.portNumber = portNumber;
- this.serverName = serverName;
- }
- public Connection getConnection() throws SQLException {
- Connection conn = null;
- conn = DriverManager.getConnection("jdbc:" +
- this.dbms + "://" + this.serverName + ":" +
- this.portNumber + "/");
- System.out.println("Connected to database");
- return conn;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement