svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.plugin / org.gvsig.sqlite / org.gvsig.sqlite.provider / src / main / java / org / gvsig / sqlite / dal / SQLiteJDBCConnection.java @ 47611
History | View | Annotate | Download (3.91 KB)
1 |
/*
|
---|---|
2 |
* To change this license header, choose License Headers in Project Properties.
|
3 |
* To change this template file, choose Tools | Templates
|
4 |
* and open the template in the editor.
|
5 |
*/
|
6 |
package org.gvsig.sqlite.dal; |
7 |
|
8 |
import java.sql.Connection; |
9 |
import java.sql.PreparedStatement; |
10 |
import java.sql.SQLException; |
11 |
import java.sql.Statement; |
12 |
import org.gvsig.fmap.dal.exception.DataException; |
13 |
import org.gvsig.fmap.dal.spi.DataTransactionServices; |
14 |
import org.gvsig.fmap.dal.store.jdbc2.JDBCConnection; |
15 |
import org.gvsig.fmap.dal.store.jdbc2.spi.ConnectionProvider; |
16 |
import org.gvsig.fmap.dal.store.jdbc2.spi.JDBCConnectionBase; |
17 |
|
18 |
/**
|
19 |
*
|
20 |
* @author fdiaz
|
21 |
*/
|
22 |
public class SQLiteJDBCConnection extends JDBCConnectionBase { |
23 |
|
24 |
public static JDBCConnection create(SQLiteHelper helper) throws SQLException { |
25 |
SQLiteConnectionParameters connectionParameters = helper.getConnectionParameters(); |
26 |
|
27 |
String key = helper.getConnectionProviderKey(connectionParameters);
|
28 |
|
29 |
SQLiteJDBCConnection conn = new SQLiteJDBCConnection(
|
30 |
helper.getTransaction(), |
31 |
helper.getConnectionProvider().getConnection(), |
32 |
key |
33 |
); |
34 |
|
35 |
return conn;
|
36 |
|
37 |
} |
38 |
|
39 |
public SQLiteJDBCConnection(DataTransactionServices transaction, Connection conn, String id) { |
40 |
super(transaction, conn, id);
|
41 |
// LOGGER.info("["+JDBCUtils.getConnId(conn)+"] createConnection() "+isInDataTransaction());
|
42 |
} |
43 |
|
44 |
public SQLiteJDBCConnection(DataTransactionServices transaction,Connection conn, String id, ConnectionProvider connectionProvider) { |
45 |
super(transaction, conn, id, connectionProvider);
|
46 |
// LOGGER.info("["+JDBCUtils.getConnId(conn)+"] createConnection() "+isInDataTransaction());
|
47 |
} |
48 |
|
49 |
@Override
|
50 |
public void close() throws SQLException { |
51 |
// if( this.transaction==null ) {
|
52 |
// LOGGER.info("["+JDBCUtils.getConnId(conn)+"] closeConnection() "+isInDataTransaction());
|
53 |
// }
|
54 |
super.close();
|
55 |
} |
56 |
|
57 |
@Override
|
58 |
public synchronized void begin() throws SQLException { |
59 |
// if(!isInTransaction()){
|
60 |
// LOGGER.info("["+JDBCUtils.getConnId(conn)+"] begin() "+isInDataTransaction());
|
61 |
// }
|
62 |
super.begin();
|
63 |
} |
64 |
|
65 |
@Override
|
66 |
public synchronized void commit() throws SQLException { |
67 |
// if( !(this.transaction!=null && this.transaction.isInProgress() )) {
|
68 |
// LOGGER.info("["+JDBCUtils.getConnId(conn)+"] commit() "+isInDataTransaction());
|
69 |
// }
|
70 |
super.commit();
|
71 |
} |
72 |
|
73 |
@Override
|
74 |
public void abort() throws DataException { |
75 |
// LOGGER.info("["+JDBCUtils.getConnId(conn)+"] abort() "+isInDataTransaction());
|
76 |
super.abort();
|
77 |
} |
78 |
|
79 |
@Override
|
80 |
public void finish() throws DataException { |
81 |
// LOGGER.info("["+JDBCUtils.getConnId(conn)+"] finish() "+isInDataTransaction());
|
82 |
super.finish();
|
83 |
} |
84 |
|
85 |
@Override
|
86 |
public void execute(String sql) throws SQLException { |
87 |
// LOGGER.info("["+JDBCUtils.getConnId(conn)+"] execute("+sql+") "+isInDataTransaction());
|
88 |
super.execute(sql);
|
89 |
} |
90 |
|
91 |
@Override
|
92 |
public PreparedStatement prepareStatement(String sql) throws SQLException { |
93 |
// LOGGER.info("["+JDBCUtils.getConnId(conn)+"] prepareStatement("+sql+") "+isInDataTransaction());
|
94 |
return super.prepareStatement(sql); |
95 |
} |
96 |
|
97 |
@Override
|
98 |
public void rollback() throws SQLException { |
99 |
// LOGGER.info("["+JDBCUtils.getConnId(conn)+"] rollback() "+isInDataTransaction());
|
100 |
super.rollback();
|
101 |
} |
102 |
|
103 |
@Override
|
104 |
public Statement createStatement() throws SQLException { |
105 |
// LOGGER.info("["+JDBCUtils.getConnId(conn)+"] createStatement() "+isInDataTransaction());
|
106 |
return super.createStatement(); |
107 |
} |
108 |
|
109 |
@Override
|
110 |
public Statement createStatement(String sql) throws SQLException { |
111 |
// LOGGER.info("["+JDBCUtils.getConnId(conn)+"] createStatement("+sql+") "+isInDataTransaction());
|
112 |
return super.createStatement(sql); |
113 |
} |
114 |
|
115 |
} |