import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
public class JDBCTest
{
public static void main(String[] args)
{
String url = "jdbc:oracle:thin:@localhost:1521:XE";
String id = "system";
String password = "nam";
Connection con;
PreparedStatement ps;
ResultSet rs;
try
{
Class.forName("oracle.jdbc.driver.OracleDriver");
con = DriverManager.getConnection(url, id, password);
System.out.println("접속 완료");
String sql = "SELECT * from member";
// String sql = "INSELET into member values(?,?,?,?,?,?,?)";
ps = con.prepareStatement(sql);
/*
ps.setString(1, "jykim");
ps.setString(2, "2222");
ps.setInt(3, 2);
ps.setString(4, "K. Jiyeon");
ps.setString(5, "study");
ps.setString(6, "01090374417");
ps.setString(7, "jykim");
*/
rs = ps.executeQuery();
while(rs.next())
{
System.out.print(rs.getString(1)+" ");
System.out.print(rs.getString(2)+" ");
System.out.print(rs.getString(3)+" ");
System.out.print(rs.getInt(4)+" ");
System.out.print(rs.getString(5)+" ");
System.out.print(rs.getString(6)+" ");
System.out.println(rs.getString(7)+" ");
}
rs.close();
ps.close();
con.close();
}
catch(Exception e)
{
e.printStackTrace();
}
}
}
result)
댓글 없음:
댓글 쓰기