Search in sources :

Example 6 with DbType

use of com.ctrip.platform.dal.daogen.enums.DbType in project dal by ctripcorp.

the class CsharpSpParamResultSetExtractor method extract.

@Override
public List<AbstractParameterHost> extract(ResultSet rs) throws SQLException {
    List<AbstractParameterHost> parameters = new ArrayList<>();
    while (rs.next()) {
        int paramMode = rs.getShort("COLUMN_TYPE");
        if (!DbUtils.validMode.contains(paramMode)) {
            continue;
        }
        CSharpParameterHost host = new CSharpParameterHost();
        DbType dbType = DbUtils.getDotNetDbType(rs.getString("TYPE_NAME"), rs.getInt("DATA_TYPE"), rs.getInt("LENGTH"), false, null);
        host.setDbType(dbType);
        host.setNullable(rs.getShort("NULLABLE") == DatabaseMetaData.columnNullable);
        if (paramMode == DatabaseMetaData.procedureColumnIn) {
            host.setDirection(ParameterDirection.Input);
        } else if (paramMode == DatabaseMetaData.procedureColumnInOut) {
            host.setDirection(ParameterDirection.InputOutput);
        } else {
            host.setDirection(ParameterDirection.Output);
        }
        host.setName(rs.getString("COLUMN_NAME"));
        host.setType(DbType.getCSharpType(host.getDbType()));
        host.setNullable(rs.getShort("NULLABLE") == DatabaseMetaData.columnNullable);
        if (host.getType() == null) {
            host.setType("string");
            host.setDbType(DbType.AnsiString);
        }
        parameters.add(host);
    }
    return parameters;
}
Also used : AbstractParameterHost(com.ctrip.platform.dal.daogen.host.AbstractParameterHost) ArrayList(java.util.ArrayList) DbType(com.ctrip.platform.dal.daogen.enums.DbType)

Aggregations

DbType (com.ctrip.platform.dal.daogen.enums.DbType)6 AbstractParameterHost (com.ctrip.platform.dal.daogen.host.AbstractParameterHost)6 ArrayList (java.util.ArrayList)6 ResultSetMetaData (java.sql.ResultSetMetaData)2 SQLException (java.sql.SQLException)2