JDBC is ignoring some datatypes like nchar, nvarchar and ntext
0 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Sreekumar_Chathambil
Posted On:   Saturday, March 20, 2004 04:12 AM

I have a table all_types in MSSQL Server 2000 the table schema is like this f1 -> tinyint f2 -> smallint f3 -> int f4 -> bigint f5 -> real f6 -> float f7 -> decimal f8 -> numeric f9 -> bit f10 -> char f11 -> varchar f12 -> binary f13 -> varbinary f14 -> datetime f15 -> image f16 -> nchar f17 -> ntext f18 -> nvarchar f19 -> smalldatetime f20 -> smallmoney f21 -> sql_variant f22 -> text    More>>

I have a table all_types in MSSQL Server 2000


the table schema is like this


f1 -> tinyint

f2 -> smallint

f3 -> int

f4 -> bigint

f5 -> real

f6 -> float

f7 -> decimal

f8 -> numeric

f9 -> bit

f10 -> char

f11 -> varchar

f12 -> binary

f13 -> varbinary

f14 -> datetime

f15 -> image

f16 -> nchar

f17 -> ntext

f18 -> nvarchar

f19 -> smalldatetime

f20 -> smallmoney

f21 -> sql_variant

f22 -> text

f23 -> timestamp

f24 -> uniqueidentifier


and i made a function to in java to find out the corresponding java.sql.Types. it is ignoring the SQL 3 types from the above (nchar, ntext, nvarchar) is there any solution for this please help meee.




try{

Statement stmt = con.createStatement();

ResultSet rs = stmt.executeQuery("SELECT * FROM ALL_TYPES");

ResultSetMetaData rsmd = rs.getMetaData();

System.out.println(rsmd.getColumnCount());

for(int iStart = 1; iStart <= rsmd.getColumnCount(); iStart++){

if(rsmd.getColumnType(iStart) == Types.ARRAY){

System.out.println(rsmd.getColumnName(iStart) + " : ARRAY");

}
else if(rsmd.getColumnType(iStart) == Types.BIGINT){

System.out.println(rsmd.getColumnName(iStart) + " : BIGINT");

}

else if(rsmd.getColumnType(iStart) == Types.BINARY){

System.out.println(rsmd.getColumnName(iStart) + " : BINARY");

}

else if(rsmd.getColumnType(iStart) == Types.BIT){

System.out.println(rsmd.getColumnName(iStart) + " : BIT");

}

else if(rsmd.getColumnType(iStart) == Types.BLOB){

System.out.println(rsmd.getColumnName(iStart) + " : BLOB");

}

else if(rsmd.getColumnType(iStart) == Types.BOOLEAN){

System.out.println(rsmd.getColumnName(iStart) + " : BOOLEAN");

}

else if(rsmd.getColumnType(iStart) == Types.CHAR){

System.out.println(rsmd.getColumnName(iStart) + " : CHAR");

}

else if(rsmd.getColumnType(iStart) == Types.CLOB){

System.out.println(rsmd.getColumnName(iStart) + " : CLOB");

}

else if(rsmd.getColumnType(iStart) == Types.DATALINK){

System.out.println(rsmd.getColumnName(iStart) + " : DATALINK");

}

else if(rsmd.getColumnType(iStart) == Types.DATE){

System.out.println(rsmd.getColumnName(iStart) + " : DATE");

}

else if(rsmd.getColumnType(iStart) == Types.DECIMAL){

System.out.println(rsmd.getColumnName(iStart) + " : DECIMAL");

}

else if(rsmd.getColumnType(iStart) == Types.DISTINCT){

System.out.println(rsmd.getColumnName(iStart) + " : DISTINCT");

}

else if(rsmd.getColumnType(iStart) == Types.DOUBLE){

System.out.println(rsmd.getColumnName(iStart) + " : DOUBLE");

}

else if(rsmd.getColumnType(iStart) == Types.FLOAT){

System.out.println(rsmd.getColumnName(iStart) + " : FLOAT");

}

else if(rsmd.getColumnType(iStart) == Types.INTEGER){

System.out.println(rsmd.getColumnName(iStart) + " : INTEGER");

}

else if(rsmd.getColumnType(iStart) == Types.JAVA_OBJECT){

System.out.println(rsmd.getColumnName(iStart) + " : JAVA_OBJECT");

}

else if(rsmd.getColumnType(iStart) == Types.LONGVARBINARY){

System.out.println(rsmd.getColumnName(iStart) + " : LONGVARBINARY");

}

else if(rsmd.getColumnType(iStart) == Types.LONGVARCHAR){

System.out.println(rsmd.getColumnName(iStart) + " : LONGVARCHAR");

}

else if(rsmd.getColumnType(iStart) == Types.NULL){

System.out.println(rsmd.getColumnName(iStart) + " : NULL");

}

else if(rsmd.getColumnType(iStart) == Types.NUMERIC){

System.out.println(rsmd.getColumnName(iStart) + " : NUMERIC");

}

else if(rsmd.getColumnType(iStart) == Types.OTHER){

System.out.println(rsmd.getColumnName(iStart) + " : OTHER");

}

else if(rsmd.getColumnType(iStart) == Types.REAL){

System.out.println(rsmd.getColumnName(iStart) + " : REAL");

}

else if(rsmd.getColumnType(iStart) == Types.REF){

System.out.println(rsmd.getColumnName(iStart) + " : REF");

}

else if(rsmd.getColumnType(iStart) == Types.SMALLINT){

System.out.println(rsmd.getColumnName(iStart) + " : SMALLINT");

}

else if(rsmd.getColumnType(iStart) == Types.STRUCT){

System.out.println(rsmd.getColumnName(iStart) + " : STRUCT");

}

else if(rsmd.getColumnType(iStart) == Types.TIME){

System.out.println(rsmd.getColumnName(iStart) + " : TIME");

}

else if(rsmd.getColumnType(iStart) == Types.TIMESTAMP){

System.out.println(rsmd.getColumnName(iStart) + " : TIMESTAMP");

}

else if(rsmd.getColumnType(iStart) == Types.TINYINT){

System.out.println(rsmd.getColumnName(iStart) + " : TYNYINT");

}

else if(rsmd.getColumnType(iStart) == Types.VARBINARY){

System.out.println(rsmd.getColumnName(iStart) + " : VARBINARY");

}

else if(rsmd.getColumnType(iStart) == Types.VARCHAR){

System.out.println(rsmd.getColumnName(iStart) + " : VARCHAR");

}

else{

System.out.println("IGNORED");

}

}

}

catch(SQLException e){


}

   <<Less
About | Sitemap | Contact