22 Desember 2011
JDBC_2
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import oracle.jdbc.pool.OracleDataSource;
public class Pengguna {
String jdbcUrl = "jdbc:oracle:thin:@localhost:1521:XE";
String userid = "hr";
String password = "02091992";
Connection conn;
Statement stmt;
ResultSet rset;
String query;
String sqlString;
public Pengguna() {
}
public void getDBConnection() throws SQLException {
OracleDataSource ds;
ds = new OracleDataSource();
ds.setURL(jdbcUrl);
conn = ds.getConnection(userid, password);
}
public ResultSet getAllEmployees() throws SQLException {
getDBConnection();
stmt = conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_READ_ONLY);
query = "crate table pengguna (id number(4), nama varchar2(20))";
System.out.println("\nExecuting query: " + query);
rset = stmt.executeQuery(query);
return rset;
}
public static void main(String[] args) throws SQLException {
Pengguna test = new Pengguna();
test.getDBConnection();
test.conn.close();
}
}
Langganan:
Posting Komentar (Atom)
Tidak ada komentar:
Posting Komentar