일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 |
- MapView
- 안드로이드 개발 2.0 강좌
- 구글 안드로이드 개발
- 인기있는 블로그 만들기
- 하루한마디영어
- 안드로이드2.0
- 스마트폰 배경화면
- SKY 시리우스
- 아이폰 배경화면
- 영어
- 안드로이드개발
- Form Stuff
- 안드로이드 개발 강좌
- android
- 안드로이드 개발 2.0
- objective-c
- 안드로이드폰
- 안드로이드2.0개발
- 안드로이드
- 구글안드로이드
- 안드로이드 배경화면
- 안드로이드 2.0 개발
- 안드로이드 개발
- sky 시리우스폰
- 스카이 안드로이드폰 시리우스 K양 동영상
- 구글 안드로이드
- 하루 한마디 영어
- 아이폰 바탕화면
- 스카이 안드로이드폰 시리우스
- 안드로이드 바탕화면
- Today
- Total
moozi
mysql jdbc 기본 본문
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;
public class JDBC01 {
static Connection conn=null;
static Statement stmt=null;
static ResultSet rs=null;
public static void main(String[] args) {
try {
Class.forName("com.mysql.jdbc.Driver");
Connection conn=DriverManager.getConnection("jdbc:mysql://localhost:3306/sampledb?useSSL=false", "root", "1234");
//mysql8.X
//Class.forName("com.mysql.cj.jdbc.Driver");
//conn=DriverManager.getConnection("jdbc:mysql://localhost:3306/jwbookdb?useSSL=false&characterEncoding=UTF-8&serverTimezone=UTC", "jwbook", "1234");
//System.out.println("연결됨");
stmt=conn.createStatement();
//insert
//stmt.executeUpdate("insert into student values('0494077','왕건','컴퓨터공학')");
//update
//stmt.executeUpdate("update student set dept='electric' where id='1091011'");
//delete
stmt.executeUpdate("delete from student where id='0494077'");
rs=stmt.executeQuery("select * from student");
System.out.println("학번\t 이름\t 학과");
System.out.println("=================================");
while(rs.next()) {
System.out.print(rs.getString("id")+"\t");
System.out.print(rs.getString("name")+"\t");
System.out.print(rs.getString("dept")+"\n");
}
}catch(Exception e) {
e.printStackTrace();
}finally {
try {
if(rs!=null) {
rs.close();
}
if(conn!=null) {
conn.close();
}
}catch(Exception e) {
e.printStackTrace();
}
}
}
}