이전 질문 게시판은 새 글 쓰기를 막았습니다. [질문 게시판]을 이용바랍니다.
Date |
2007/06/14 23:15:06 |
Name |
마르샤 |
Subject |
자바 소스 수정 부탁드립니다. |
import java.awt.*;
import java.sql.*;
import java.io.*;
public class stud extends Frame{
public static void main(String[] args) {
String driver = "sun.jdbc.odbc.JdbcOdbcDriver";
String url = "jdbc:odbc:jdbc" ;
Connection con = null;
Statement stmt = null;
String sql = "Insert into member (num, name, addr, phone) values";
String num, name, addr, phone;
try{
public stud (String str) { <--이부분
super(str);
setLayout(new FlowLayout());//화면에 배치
Label lbl1 = new Label("학번 입력");
Label lbl2 = new Label("이름 입력");
Label lbl3 = new Label("주소 입력");
Label lbl4 = new Label("전화번호 입력");
TextField txt1 = new TextField(8);
TextField txt2 = new TextField(4);
TextField txt3 = new TextField();
TextField txt4 = new TextField();
add(lbl1); add(txt1); add(lbl2); add(txt2);add(lbl3); add(txt3);add(lbl4); add(txt4);//화면에 첨부
setSize(300,200);//Frame 크기
setVisible(true);//Frame을 띄어주는 것
}
num = txt1;
name = txt2;
addr = txt3;
phone = txt4;
sql += "('" + num +"', '" + name + "', '" + addr + "', '" + phone + "')";
System.out.println( sql );
Class. forName(driver);
con = DriverManager. getConnection(url, " master ", "java");
stmt = con.createStatement();
stmt.executeUpdate(sql);
System.out.println("데이터베이스 연결 성공!");
}
catch(Exception e){
System.out.println("데이터베이스 연결 실패!");
}
finally{
try{
if(con != null) con.close();
if(stmt != null) stmt.close();
}
catch(Exception e){
System.out.println( e. getMessage());
}
}
}
}
인데 에러나는 부분은 화살표로 표시하였습니다.
|
통합규정 1.3 이용안내 인용
"Pgr은 '명문화된 삭제규정'이 반드시 필요하지 않은 분을 환영합니다.
법 없이도 사는 사람, 남에게 상처를 주지 않으면서 같이 이야기 나눌 수 있는 분이면 좋겠습니다."
|