-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathConnect.java
43 lines (32 loc) · 1 KB
/
Connect.java
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
31
32
33
34
35
36
37
38
39
40
41
42
43
import java.sql.*;
public class Connect
{
private static String info;
public static Connection getConnection()
{
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
String dataSourceName = "RVB.mdb";
String dbURL = "jdbc:odbc:Driver={Microsoft Access Driver (*.mdb)};DBQ=";
dbURL += dataSourceName + ";DriverID=22;READONLY=true)";
return DriverManager.getConnection(dbURL,"","");
}
catch ( ClassNotFoundException cnfex )
{
cnfex.printStackTrace();
info=info+"Connection unsuccessful\n" + cnfex.toString();
}
catch ( SQLException sqlex )
{
sqlex.printStackTrace();
//info=info+"Connection unsuccessful\n" +sqlex.toString();
}
catch ( Exception excp )
{
excp.printStackTrace();
info=info+excp.toString();
}
return null;
}
}