-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathconnector.java
More file actions
executable file
·61 lines (58 loc) · 2.2 KB
/
connector.java
File metadata and controls
executable file
·61 lines (58 loc) · 2.2 KB
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
/*
* connector.java
*
* Created on 8 ßíâàðü 2008 ã., 15:25
*
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
*/
import java.sql.*;
/**
*
* @author Âèòàëèê
*/
public class connector {
/** Creates a new instance of connector */
public connector() {
}
/**
*
*/
public static java.sql.Connection get_connection_to_firebird(String path_to_server,
String path_to_database,
Integer port,
String user,
String password){
//java.sql.Driver driver=null;
java.sql.Connection connection=null;
String driverName = "org.firebirdsql.jdbc.FBDriver";
String database_protocol="jdbc:firebirdsql://";
String database_dialect="?sql_dialect=3";
String database_server=null;
String database_port=null;
//String databaseURL = "jdbc:firebirdsql://localhost:3050/d:/work/sadik/sadik.gdb?sql_dialect=3";
if((path_to_server=="")||(path_to_server==null)){
database_server="localhost";
}else{
database_server=path_to_server;
}
if((port==null)||(port==0)){
database_port="3050";
}else{
database_port=Integer.toString(port);
}
String databaseURL=database_protocol+database_server+":"+database_port+"/"+path_to_database+database_dialect;
try{
//System.out.println("Ïîïûòêà çàãðóçèòü äðàéâåð");
Class.forName(driverName);
//System.out.println("Ïîïûòêà ñîåäíèíåíèÿ="+databaseURL);
connection=java.sql.DriverManager.getConnection(databaseURL,user,password);
connection.setAutoCommit(false);
}catch(SQLException sqlexception){
System.out.println("íå óäàëîñü ïîäêëþ÷èòüñÿ ê áàçå äàííûõ");
}catch(ClassNotFoundException classnotfoundexception){
System.out.println("íå íàéäåí êëàññ");
}
return connection;
}
}