펼쳐두기..
오류;;
----------------------------------------------------------------------------------------------------------
com.ibm.db2.jcc.c.DisconnectException: [ibm][db2][jcc][t4][1076][11154] java.io.UnsupportedEncodingException이 발생했습니다. 세부사항은 첨부한 Throwable을 참조하십시오.
at com.ibm.db2.jcc.b.db.b(db.java:1318)
at com.ibm.db2.jcc.b.gb.Wc(gb.java:3043)
at com.ibm.db2.jcc.b.gb.b(gb.java:2827)
at com.ibm.db2.jcc.b.gb.b(gb.java:2748)
at com.ibm.db2.jcc.b.gb.a(gb.java:2618)
at com.ibm.db2.jcc.b.gb.b(gb.java:2543)
at com.ibm.db2.jcc.b.gb.a(gb.java:2468)
at com.ibm.db2.jcc.b.gb.g(gb.java:132)
at com.ibm.db2.jcc.b.gb.a(gb.java:39)
at com.ibm.db2.jcc.b.w.a(w.java:34)
at com.ibm.db2.jcc.b.vb.g(vb.java:139)
at com.ibm.db2.jcc.c.fg.n(fg.java:1177)
at com.ibm.db2.jcc.c.gg.eb(gg.java:1862)
at com.ibm.db2.jcc.c.gg.d(gg.java:2295)
at com.ibm.db2.jcc.c.gg.V(gg.java:424)
at com.ibm.db2.jcc.c.gg.executeQuery(gg.java:407)
at com.shift.test.DB2Sample.main(DB2Sample.java:23)
Caused by: java.io.UnsupportedEncodingException: Cp1363C
at sun.io.Converters.getConverterClass(Converters.java:215)
at sun.io.Converters.newConverter(Converters.java:248)
at sun.io.ByteToCharConverter.getConverter(ByteToCharConverter.java:64)
at java.lang.StringCoding.decode(StringCoding.java:226)
at java.lang.String.<init>(String.java:320)
at com.ibm.db2.jcc.b.db.b(db.java:1315)
... 16 more
샘플코드
----------------------------------------------------------------------------------------------------------
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.ResultSetMetaData;
import java.sql.SQLException;
public class DB2Sample {
/**
* @param args
*/
public static void main(String[] args) {
try {
Class.forName("com.ibm.db2.jcc.DB2Driver").newInstance();
Connection conn = DriverManager.getConnection("jdbc:db2://localhost:50000/SAMPLE", "user", "password");
PreparedStatement pstmt = conn.prepareStatement("SELECT * FROM DB2_TEST");
ResultSet rset = pstmt.executeQuery();
ResultSetMetaData meta = rset.getMetaData();
printColumnInfo(meta);
while(rset.next()) {
System.out.println(rset.getObject("TEST"));
}
rset.close();
pstmt.close();
conn.close();
} catch(ClassNotFoundException cnfe) {
System.out.println("CNFE : " + cnfe.getMessage());
} catch(IllegalAccessException iae) {
System.out.println("IAE : " + iae.getMessage());
} catch(InstantiationException ie) {
System.out.println("IE : " + ie.getMessage());
} catch(SQLException sqle) {
System.out.println("SQLE : " + sqle.getMessage());
sqle.printStackTrace();
}
}
public static void printColumnInfo(ResultSetMetaData p_rsmd) {
try {
StringBuffer sb = new StringBuffer();
sb.append("\n=[ResultSet MetaData Infomation]========================================\n");
sb.append(" 총 컬럼 갯수 : ").append(p_rsmd.getColumnCount()).append("\n");
sb.append("----------------------------------------------------------------------\n");
for (int i = 1; i < p_rsmd.getColumnCount()+1; i++) {
sb.append("getCatalogName : "+p_rsmd.getCatalogName(i)).append("\n");
sb.append("getColumnClassName : "+p_rsmd.getColumnClassName(i)).append("\n");
sb.append("getColumnDisplaySize : "+p_rsmd.getColumnDisplaySize(i)).append("\n");
sb.append("getColumnLabel : "+p_rsmd.getColumnLabel(i)).append("\n");
sb.append("getColumnName : "+p_rsmd.getColumnName(i)).append("\n");
sb.append("getColumnType : "+p_rsmd.getColumnType(i)).append("\n");
sb.append("getColumnTypeName : "+p_rsmd.getColumnTypeName(i)).append("\n");
sb.append("getPrecision : "+p_rsmd.getPrecision(i)).append("\n");
sb.append("getScale : "+p_rsmd.getScale(i)).append("\n");
sb.append("getSchemaName : "+p_rsmd.getSchemaName(i)).append("\n");
sb.append("getTableName : "+p_rsmd.getTableName(i)).append("\n");
sb.append("isAutoIncrement : "+p_rsmd.isAutoIncrement(i)).append("\n");
sb.append("isCaseSensitive : "+p_rsmd.isCaseSensitive(i)).append("\n");
sb.append("isCurrency : "+p_rsmd.isCurrency(i)).append("\n");
sb.append("isDefinitelyWritable : "+p_rsmd.isDefinitelyWritable(i)).append("\n");
sb.append("isNullable : "+p_rsmd.isNullable(i)).append("\n");
if(p_rsmd.isNullable(i) == ResultSetMetaData.columnNoNulls){
sb.append("isNullable : Not Null").append("\n");;
}else{
sb.append("isNullable : Nullable").append("\n");;
}
sb.append("isReadOnly : "+p_rsmd.isReadOnly(i)).append("\n");;
sb.append("isSearchable : "+p_rsmd.isSearchable(i)).append("\n");;
sb.append("isSigned : "+p_rsmd.isSigned(i)).append("\n");;
sb.append("isWritable : "+p_rsmd.isWritable(i)).append("\n");;
sb.append("----------------------------------------------------------------------\n\n");
}
sb.append("======================================================================");
System.out.println(sb.toString());
} catch(SQLException sqle) {
System.out.println("META SQLE : " + sqle.getMessage());
}
}
}
No comments:
Post a Comment