📄 encodestatement.java
字号:
package mapcenter.service;
import java.sql.Statement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.SQLWarning;
import java.sql.Connection;
import java.io.UnsupportedEncodingException;
public class EncodeStatement implements Statement {
private Statement statement;
private String OrigCharSet, TargCharSet;
private static Log log = LogFactory.getLog("WebGIS");
public EncodeStatement(Statement statement, String OrigCharSet, String TargCharSet) {
this.statement = statement;
this.OrigCharSet = OrigCharSet;
this.TargCharSet = TargCharSet;
}
public ResultSet executeQuery(String parm1) throws java.sql.SQLException {
try{
parm1 = new String(parm1.getBytes(TargCharSet), OrigCharSet);
}catch(UnsupportedEncodingException e){
log.error(e.getMessage());
}
//============== 返回EncodeResultSet ================
return new EncodeResultSet(statement.executeQuery(parm1),OrigCharSet, TargCharSet);
}
public int executeUpdate(String parm1) throws java.sql.SQLException {
try{
parm1 = new String(parm1.getBytes(TargCharSet), OrigCharSet);
}catch(UnsupportedEncodingException e){
log.error(e.getMessage());
}
return statement.executeUpdate(parm1);
}
public void close() throws java.sql.SQLException {
statement.close();
}
public int getMaxFieldSize() throws java.sql.SQLException {
return statement.getMaxFieldSize();
}
public void setMaxFieldSize(int parm1) throws java.sql.SQLException {
statement.setMaxFieldSize(parm1);
}
public int getMaxRows() throws java.sql.SQLException {
return statement.getMaxRows();
}
public void setMaxRows(int parm1) throws java.sql.SQLException {
statement.setMaxRows(parm1);
}
public void setEscapeProcessing(boolean parm1) throws java.sql.SQLException {
statement.setEscapeProcessing(parm1);
}
public int getQueryTimeout() throws java.sql.SQLException {
return statement.getQueryTimeout();
}
public void setQueryTimeout(int parm1) throws java.sql.SQLException {
statement.setQueryTimeout(parm1);
}
public void cancel() throws java.sql.SQLException {
statement.cancel();
}
public SQLWarning getWarnings() throws java.sql.SQLException {
return statement.getWarnings();
}
public void clearWarnings() throws java.sql.SQLException {
statement.clearWarnings();
}
public void setCursorName(String parm1) throws java.sql.SQLException {
statement.setCursorName(parm1);
}
public boolean execute(String parm1) throws java.sql.SQLException {
try{
parm1 = new String(parm1.getBytes(TargCharSet), OrigCharSet);
}catch(UnsupportedEncodingException e){
log.error(e.getMessage());
}
return statement.execute(parm1);
}
//============== 封装成EncodeResultSet返回 ======================================
public ResultSet getResultSet() throws java.sql.SQLException {
return new EncodeResultSet(statement.getResultSet(),OrigCharSet,TargCharSet);
}
public int getUpdateCount() throws java.sql.SQLException {
return statement.getUpdateCount();
}
public boolean getMoreResults() throws java.sql.SQLException {
return statement.getMoreResults();
}
public void setFetchDirection(int parm1) throws java.sql.SQLException {
statement.setFetchDirection(parm1);
}
public int getFetchDirection() throws java.sql.SQLException {
return statement.getFetchDirection();
}
public void setFetchSize(int parm1) throws java.sql.SQLException {
statement.setFetchSize(parm1);
}
public int getFetchSize() throws java.sql.SQLException {
return statement.getFetchSize();
}
public int getResultSetConcurrency() throws java.sql.SQLException {
return statement.getResultSetConcurrency();
}
public int getResultSetType() throws java.sql.SQLException {
return statement.getResultSetType();
}
public void addBatch(String parm1) throws java.sql.SQLException {
try{
parm1 = new String(parm1.getBytes(TargCharSet),OrigCharSet);
}catch(UnsupportedEncodingException e){
log.error(e.getMessage());
}
statement.addBatch(parm1);
}
public void clearBatch() throws java.sql.SQLException {
statement.clearBatch();
}
public int[] executeBatch() throws java.sql.SQLException {
return statement.executeBatch();
}
public Connection getConnection() throws java.sql.SQLException {
return new EncodeConnection(statement.getConnection(), OrigCharSet,TargCharSet);
}
public boolean getMoreResults(int parm1) throws java.sql.SQLException {
return statement.getMoreResults(parm1);
}
//================== 封装成EncodeResultSet返回 ====================================
public ResultSet getGeneratedKeys() throws java.sql.SQLException {
return new EncodeResultSet(statement.getGeneratedKeys(),OrigCharSet,TargCharSet);
}
public int executeUpdate(String parm1, int parm2) throws java.sql.SQLException {
try{
parm1 = new String(parm1.getBytes(TargCharSet), OrigCharSet);
}catch(UnsupportedEncodingException e){
log.error(e.getMessage());
}
return statement.executeUpdate(parm1, parm2);
}
public int executeUpdate(String parm1, int[] parm2) throws java.sql.SQLException {
try{
parm1 = new String(parm1.getBytes(TargCharSet), OrigCharSet);
}catch(UnsupportedEncodingException e){
log.error(e.getMessage());
}
return statement.executeUpdate(parm1, parm2);
}
public int executeUpdate(String parm1, String[] parm2) throws java.sql.SQLException {
try{
parm1 = new String(parm1.getBytes(TargCharSet), OrigCharSet);
for(int i=0; i < parm2.length; i++){
parm2[i] = new String(parm2[i].getBytes(TargCharSet), OrigCharSet);
}
}catch(UnsupportedEncodingException e){
log.error(e.getMessage());
}
return statement.executeUpdate(parm1, parm2);
}
public boolean execute(String parm1, int parm2) throws java.sql.SQLException {
try{
parm1 = new String(parm1.getBytes(TargCharSet), OrigCharSet);
}catch(UnsupportedEncodingException e){
log.error(e.getMessage());
}
return statement.execute(parm1, parm2);
}
public boolean execute(String parm1, int[] parm2) throws java.sql.SQLException {
try{
parm1 = new String(parm1.getBytes(TargCharSet), OrigCharSet);
}catch(UnsupportedEncodingException e){
log.error(e.getMessage());
}
return statement.execute(parm1, parm2);
}
public boolean execute(String parm1, String[] parm2) throws java.sql.SQLException {
try{
parm1 = new String(parm1.getBytes(TargCharSet), OrigCharSet);
for(int i=0; i < parm2.length; i++){
parm2[i] = new String(parm2[i].getBytes(TargCharSet), OrigCharSet);
}
}catch(UnsupportedEncodingException e){
log.error(e.getMessage());
}
return statement.execute(parm1,parm2);
}
public int getResultSetHoldability() throws java.sql.SQLException {
return statement.getResultSetHoldability();
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -