diff --git a/src/main/java/org/redkale/source/DataJdbcSource.java b/src/main/java/org/redkale/source/DataJdbcSource.java index 18c512eee..9b7340f6d 100644 --- a/src/main/java/org/redkale/source/DataJdbcSource.java +++ b/src/main/java/org/redkale/source/DataJdbcSource.java @@ -2881,11 +2881,11 @@ public class DataJdbcSource extends AbstractDataSqlSource { @Override public Serializable getObject(Attribute attr, int index, String columnLabel) { Class t = attr.type(); - if (t == int.class) { - return index > 0 ? getInt(index) : getInt(columnLabel); - } else if (t == String.class) { + if (t == String.class) { return index > 0 ? getString(index) : getString(columnLabel); - } else if (t == long.class) { + } else if (t == int.class || t == Integer.class) { + return index > 0 ? getInteger(index) : getInteger(columnLabel); + } else if (t == long.class || t == Long.class) { return index > 0 ? getLong(index) : getLong(columnLabel); } else if (t == java.util.Date.class) { Object val = index > 0 ? getObject(index) : getObject(columnLabel); @@ -2965,38 +2965,7 @@ public class DataJdbcSource extends AbstractDataSqlSource { } } - public int getInt(int index) { - try { - return rr.getInt(index); - } catch (SQLException e) { - throw new SourceException(e); - } - } - - public int getInt(String column) { - try { - return rr.getInt(column); - } catch (SQLException e) { - throw new SourceException(e); - } - } - - public long getLong(int index) { - try { - return rr.getLong(index); - } catch (SQLException e) { - throw new SourceException(e); - } - } - - public long getLong(String column) { - try { - return rr.getLong(column); - } catch (SQLException e) { - throw new SourceException(e); - } - } - + @Override public String getString(int index) { try { return rr.getString(index); @@ -3005,6 +2974,7 @@ public class DataJdbcSource extends AbstractDataSqlSource { } } + @Override public String getString(String column) { try { return rr.getString(column); @@ -3013,6 +2983,132 @@ public class DataJdbcSource extends AbstractDataSqlSource { } } + @Override + public byte[] getBytes(int index) { + try { + return rr.getBytes(index); + } catch (SQLException e) { + throw new SourceException(e); + } + } + + @Override + public byte[] getBytes(String column) { + try { + return rr.getBytes(column); + } catch (SQLException e) { + throw new SourceException(e); + } + } + + @Override + public Boolean getBoolean(int index) { + try { + return rr.getBoolean(index); + } catch (SQLException e) { + throw new SourceException(e); + } + } + + @Override + public Boolean getBoolean(String column) { + try { + return rr.getBoolean(column); + } catch (SQLException e) { + throw new SourceException(e); + } + } + + @Override + public Short getShort(int index) { + try { + return rr.getShort(index); + } catch (SQLException e) { + throw new SourceException(e); + } + } + + @Override + public Short getShort(String column) { + try { + return rr.getShort(column); + } catch (SQLException e) { + throw new SourceException(e); + } + } + + @Override + public Integer getInteger(int index) { + try { + return rr.getInt(index); + } catch (SQLException e) { + throw new SourceException(e); + } + } + + @Override + public Integer getInteger(String column) { + try { + return rr.getInt(column); + } catch (SQLException e) { + throw new SourceException(e); + } + } + + @Override + public Float getFloat(int index) { + try { + return rr.getFloat(index); + } catch (SQLException e) { + throw new SourceException(e); + } + } + + @Override + public Float getFloat(String column) { + try { + return rr.getFloat(column); + } catch (SQLException e) { + throw new SourceException(e); + } + } + + @Override + public Long getLong(int index) { + try { + return rr.getLong(index); + } catch (SQLException e) { + throw new SourceException(e); + } + } + + @Override + public Long getLong(String column) { + try { + return rr.getLong(column); + } catch (SQLException e) { + throw new SourceException(e); + } + } + + @Override + public Double getDouble(int index) { + try { + return rr.getDouble(index); + } catch (SQLException e) { + throw new SourceException(e); + } + } + + @Override + public Double getDouble(String column) { + try { + return rr.getDouble(column); + } catch (SQLException e) { + throw new SourceException(e); + } + } + @Override public EntityInfo getEntityInfo() { return info; diff --git a/src/main/java/org/redkale/source/DataResultSetRow.java b/src/main/java/org/redkale/source/DataResultSetRow.java index 1726a1692..cb1b8363e 100644 --- a/src/main/java/org/redkale/source/DataResultSetRow.java +++ b/src/main/java/org/redkale/source/DataResultSetRow.java @@ -18,14 +18,120 @@ public interface DataResultSetRow { // 可以为空 public @Nullable EntityInfo getEntityInfo(); - // index从1开始 - public Object getObject(int index); + // columnIdex从1开始 + public Object getObject(int columnIdex); public Object getObject(String columnLabel); - // index从1开始 - default Serializable getObject(Attribute attr, int index, String columnLabel) { - return DataResultSet.getRowColumnValue(this, attr, index, columnLabel); + // columnIdex从1开始 + default Serializable getObject(Attribute attr, int columnIndex, String columnLabel) { + return DataResultSet.getRowColumnValue(this, attr, columnIndex, columnLabel); + } + + // columnIdex从1开始 + public String getString(int columnIdex); + + public String getString(String columnLabel); + + // columnIdex从1开始 + public byte[] getBytes(int columnIdex); + + public byte[] getBytes(String columnLabel); + + // columnIdex从1开始 + public Boolean getBoolean(int columnIdex); + + public Boolean getBoolean(String columnLabel); + + // columnIdex从1开始 + public Short getShort(int columnIdex); + + public Short getShort(String columnLabel); + + // columnIdex从1开始 + public Integer getInteger(int columnIdex); + + public Integer getInteger(String columnLabel); + + // columnIdex从1开始 + public Float getFloat(int columnIdex); + + public Float getFloat(String columnLabel); + + // columnIdex从1开始 + public Long getLong(int columnIdex); + + public Long getLong(String columnLabel); + + // columnIdex从1开始 + public Double getDouble(int columnIdex); + + public Double getDouble(String columnLabel); + + // columnIdex从1开始 + default boolean getBoolean(int columnIdex, boolean defValue) { + Boolean val = getBoolean(columnIdex); + return val == null ? defValue : val; + } + + default boolean getBoolean(String columnLabel, boolean defValue) { + Boolean val = getBoolean(columnLabel); + return val == null ? defValue : val; + } + + // columnIdex从1开始 + default short getShort(int columnIdex, short defValue) { + Short val = getShort(columnIdex); + return val == null ? defValue : val; + } + + default short getShort(String columnLabel, short defValue) { + Short val = getShort(columnLabel); + return val == null ? defValue : val; + } + + // columnIdex从1开始 + default int getInteger(int columnIdex, int defValue) { + Integer val = getInteger(columnIdex); + return val == null ? defValue : val; + } + + default int getInteger(String columnLabel, int defValue) { + Integer val = getInteger(columnLabel); + return val == null ? defValue : val; + } + + // columnIdex从1开始 + default float getFloat(int columnIdex, float defValue) { + Float val = getFloat(columnIdex); + return val == null ? defValue : val; + } + + default float getFloat(String columnLabel, float defValue) { + Float val = getFloat(columnLabel); + return val == null ? defValue : val; + } + + // columnIdex从1开始 + default long getLong(int columnIdex, long defValue) { + Long val = getLong(columnIdex); + return val == null ? defValue : val; + } + + default long getLong(String columnLabel, long defValue) { + Long val = getLong(columnLabel); + return val == null ? defValue : val; + } + + // columnIdex从1开始 + default double getDouble(int columnIdex, double defValue) { + Double val = getDouble(columnIdex); + return val == null ? defValue : val; + } + + default double getDouble(String columnLabel, double defValue) { + Double val = getDouble(columnLabel); + return val == null ? defValue : val; } /**