<%@ page contentType="text/html; charset=euc-kr" %>
<%@ page import="java.sql.*" %>
<%@ page import="java.util.*" %>
<%
Connection conn = null;
Statement stmt = null;
PreparedStatement ps = null;
ResultSet rs = null;
try {
String smsquery = "SELECT * FROM table";
Class.forName("oracle.jdbc.driver.OracleDriver");
conn = DriverManager.getConnection("jdbc:oracle:thin:@(DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.103)(PORT = 1521)) ) (CONNECT_DATA = (SERVICE_NAME = INTDEV) ) )","test","test");
/*
DatabaseMetaData dbmd = null;
dbmd = conn.getMetaData();
rs = dbmd.getCatalogs();
while(rs.next()) {
out.println("TABLE_CAT [" + rs.getString(1) + "]<br>");
}
rs = dbmd.getColumns(null,null, "sms", "sm_msg");
while(rs.next()) {
out.println("column_name [" + rs.getString(4) + "]<br>");
out.println("type_name [" + rs.getString(6) + "]");
out.println("column_size [" + rs.getInt(7) + "]");
}
*/
ps = conn.prepareStatement(smsquery);
rs = ps.executeQuery();
ResultSetMetaData rd= rs.getMetaData();
int numberOfColumns = rd.getColumnCount();
for(int i=0; i<numberOfColumns; i++) {
out.println("name [" + rd.getColumnName(i+1) + "] size[" + rd.getColumnDisplaySize(i+1) + "]<br>");
}
} catch (Exception e) {
out.println(e.getMessage());
} finally {
if (rs != null) {
try {rs.close();} catch(Exception e) {}
}
if (stmt != null) {
try {stmt.close();} catch(Exception e) {}
}
if (conn != null) {
try {conn.close();} catch(Exception e) {}
}
}
%>
'Java' 카테고리의 다른 글
[Java] 자바 소스코드 많은 추천 싸이트!!! (0) | 2010.06.03 |
---|---|
[Java] String과 StringBuffer의 속도 차이 (0) | 2010.05.26 |
[Java] GIF 이미지 생성 (0) | 2009.12.22 |
[Java] 원격디버깅 (0) | 2009.11.25 |
[Java] 싱클톤 패턴 (0) | 2009.10.22 |