import java.sql.*;
public class DBTest{
public static void main(String args[]) throws Exception{
new DBTest();
}
public DBTest(){
Connection conn=null;
Statement stmt=null;
ResultSet rs=null;
String sql="select * from en_contents";
String url = "jdbc:oracle:thin:@192.168.1.50:1521:ORCL";
String id = "myid";
String pass = "mypass";
try {
//클래스를 메모리에 로딩 시키는 것
Class.forName("oracle.jdbc.driver.OracleDriver");
} catch (Exception e) {
e.printStackTrace();
}
try {
conn= DriverManager.getConnection(url,id,pass);
stmt = conn.createStatement();
rs=stmt.executeQuery(sql);
while (rs.next()) {
System.out.println(rs.getString(1));
}
if(rs!=null)rs.close();
if(stmt!=null)stmt.close();
if(conn!=null)conn.close();
} catch (SQLException e) {
e.printStackTrace();
}
}
}
'etc > old' 카테고리의 다른 글
쿠키에서 한글 깨지는 문제 해결 (0) | 2008.11.26 |
---|---|
ibatis에서 insert하고 id값 받기 (DB별) (0) | 2008.11.14 |
웹 서버 설치 (Apache 2.2 + Tomcat 6.0 + Mysql + Svn) (0) | 2008.11.05 |
STRUTS2 - Login with Session (1) | 2008.11.04 |
Struts2 - Login Test with Validator (0) | 2008.11.04 |