-
Notifications
You must be signed in to change notification settings - Fork 227
Expand file tree
/
Copy pathJDBC30DataHandler.java
More file actions
53 lines (46 loc) · 1.27 KB
/
JDBC30DataHandler.java
File metadata and controls
53 lines (46 loc) · 1.27 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
/*
* Jython Database Specification API 2.0
*
*
* Copyright (c) 2002 brian zimmer <bzimmer@ziclix.com>
*
*/
package com.ziclix.python.sql;
import org.python.core.PyObject;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.sql.ParameterMetaData;
/**
* Support for JDBC 3.x additions, notably ParameterMetaData.
*
* @author brian zimmer
*/
public class JDBC30DataHandler extends FilterDataHandler {
static {
try {
Class.forName("java.sql.ParameterMetaData");
} catch (ClassNotFoundException e) {
throw new RuntimeException("JDBC3.0 required to use this DataHandler");
}
}
/**
* Handle JDBC 3.0 additions.
*
*/
public JDBC30DataHandler(DataHandler datahandler) {
super(datahandler);
}
/**
* Use ParameterMetaData if available to dynamically cast to the appropriate
* JDBC type.
*
* @param stmt the prepared statement
* @param index the index currently being used
* @param object the object to be set on the statement
* @throws SQLException
*/
public void setJDBCObject(PreparedStatement stmt, int index, PyObject object) throws SQLException {
ParameterMetaData meta = stmt.getParameterMetaData();
super.setJDBCObject(stmt, index, object, meta.getParameterType(index));
}
}