-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMSconnect.java
More file actions
30 lines (28 loc) · 858 Bytes
/
Copy pathMSconnect.java
File metadata and controls
30 lines (28 loc) · 858 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
package PDBMS;
import java.sql.*;
public class MSconnect {
static Connection con=null;
static String ip = "localhost:49172",db = "pdms",un = "pavan",pass = "321654987";
public static Connection ConnectDB(){
String ConnectionURL = null;
try
{
Class.forName("net.sourceforge.jtds.jdbc.Driver");
ConnectionURL = "jdbc:jtds:sqlserver://" + ip +";databaseName="+ db + ";user=" + un+ ";password=" + pass + ";";
con = DriverManager.getConnection(ConnectionURL);
}
catch (SQLException se)
{
se.printStackTrace();
}
catch (ClassNotFoundException e)
{
e.printStackTrace();
}
catch (Exception e)
{
e.printStackTrace();
}
return con;
}
}