(앞 질문에서 이어지는 소스...)
class User {
private String id;
static {
try {
Class.forName("oracle.jdbc.driver.OracleDriver");
}
catch (Exception e) {
}
}
private static Connection getConnection() throws Exception {
String url = "jdbc:oracle:thid:@210.220.206.7:1521:devora8";
String user = "phoenix";
String psw = "phoenix";
return DriverManager.getConnection(url,user,psw);
}
public User(String id) throws Exception {
this.id = id;
Connection con = getConnection();
Statement stmt = con.createStatement();
stmt.executeUpdate("CREATE TABLE "+id+" (name VARCHAR2(10), phone VARCHAR2(14))");
stmt.close();
con.close();
}
public void clear() throws Exception {
Connection con = getConnection();
Statement stmt = con.createStatement();
stmt.executeUpdate("DROP TABLE "+id);
stmt.close();
con.close();
}
public boolean insertMember(String name, String pnumber) throws Exception {
Connection con = getConnection();
Statement stmt = con.createStatement();
int value = stmt.executeUpdate("INSERT INTO "+id+" VALUES ('"+name+"', '"+pnumber+"')");
stmt.close();
con.close();
if (value == 1)
return true;
return false;
}
public int deleteMember(String name) throws Exception {
Connection con = getConnection();
Statement stmt = con.createStatement();
int value = stmt.executeUpdate("DELETE FROM "+id+" WHERE name = '"+name+"'");
stmt.close();
con.close();
return value;
}
public String referTo(String name) throws Exception {
Connection con = getConnection();
Statement stmt = con.createStatement();
ResultSet result = stmt.executeQuery("SELECT * FROM "+id+" WHERE name LIKE '%"+name+"%'");
try {
if (!result.next())
return "그런 이름은 존재하지 않습니다.";
StringBuffer list = new StringBuffer("");
while(true) {
list.append("이름 : "+result.getString("name")+", 전화번호 : "+result.getString("phone")+"\n");
if (!result.next())
break;
}
return list.toString();
}
finally {
stmt.close();
con.close();
}
}
}
이렇게 했는데요...
[pyromania@dev test]$ java ProgramCode1_3 pyro
***********************************************
* 번호부 보기 : view [이름] *
* 회원 더하기 : add [이름] [전화] *
* 회원 지우기 : del [이름] *
* 종료하기 : quit *
***********************************************
Exception in thread "main" java.sql.SQLException: Sub Protocol must be specified in connection URL
at oracle.jdbc.dbaccess.DBError.check_error(DBError.java:352)
at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:102)
at java.sql.DriverManager.getConnection(DriverManager.java:517)
at java.sql.DriverManager.getConnection(DriverManager.java:177)
at User.getConnection(ProgramCode1_3.java:76)
at User.<init>(ProgramCode1_3.java:81)
at ProgramCode1_3.main(ProgramCode1_3.java:22)
이렇게 에러가 뜨네요
어찌해야할지...
컴파일은 무사히 됐구요
환경은 LINUX6.1
ORACLE 8.0.5
JDK 1.3에
jdbc로는 classes111.zip파일을 놨거든요?
|