±Û¾´ÀÌ :¼ö(sue) 2000³â 5¿ù 23ÀÏ 09:57:10
jdbcÇÁ·Î±×·¡¹Ö Àä.. Á˼ÛÇÏÁö¸¸ ÁÖ¼® Á» ´Þ¾ÆÁÖ¼¼¿ä!
ÇØ ÁÖ½Ã¸é ¸Å¿ì °¨»ç! °¨»ç!
(¹øÈ£´Â Á¦°¡ ÀÓÀÇ·Î ´Þ¾Ò½À´Ï´Ù.)
1  import java.sql.*;  
2
3  public class myTestDB01{
4	
5	public static void main(String[] args){
6		String url = "jdbc:oracle:thin@203.269.131.233:1521:SID";
7		String query = "Select name,class,age from edu_info";
8		
9		Connection myCon = null;
10		Statment stmt = null;
11		
12		try{
13			Class.forName("Oracle.jdbc.driver.OracleDriver");
14		}catch(ClassNotFoundException e) {
15			System.err.println(e.getmessage());
16		}
17		
18		myCon = DriverManager.getConnection(url,"moonstar",
19		"moon1234");
20		
21		stmt = con.createstatment();
22		ResultSet rs= stmt.executeQuery(query);
23		
24		while(rs.netx()){
25			String col1 = rs.getString(1);
26		    String col2 = rs.getString(2);
27		    int col3 = rs.getInt(3);
28		    
29		    System.out.println(" " + col1 + " : " +  col2 + " : " + col3);
30		    
31		}
32		rs.close();
33		stmt.close();
34		myCon.close();
35   }
36 }