전체 글
-
[MySQL] Table 생성, 제약조건, 컬럼 추가/수정, 외래키 설정, insertDataBase/MySQL 2022. 9. 9. 16:23
Table 생성 MySQL Workbench 접속 자료형 제약조건 자주 쓰는 자료형 -int: 정수 자료형(float, bouble은 실수) -varchar: 문자열 자료형, 가변길이(char은 고정 길이) -text: 긴 문자열은 'text'로 별도 저장 -datetime: 날짜 자료형 저장 -tinyint: -128에서 127까지 저장 자주 쓰는 제약 조건 -not null: 빈 값은 받지 않는다는 뜻(null은 빈 값 허용) -auto_increment -unsigned: 0과 양수만 허용 -zerofill: 숫자의 자리수가 고정된 경우 빈 자리에 0을 넣음 -default now(): 날짜 컬럼의 기본값을 현재 시간으로 AUTO_INCREMENT -오라클의 sequence를 대시하는 자동 ..
-
[JDBC] singletonDataBase/JDBC 2022. 9. 9. 16:04
DTO 생성 -Generate Getters and Setters... 사용해 메서드 생성 import java.sql.Date; public class MemberDto { private int num; private String name; private String phone; private Date birth; private int bpoint; private Date joindate; private String gender; private int age; public int getNum() { return num; } public void setNum(int num) { this.num = num; } public String getName() { return name; } public void ..
-
[JDBC] DTO, DAODataBase/JDBC 2022. 9. 9. 15:58
DTO -Data Tranfer Object 다른 말로 JAVA Bean. -다수의 자료를 객체에 한번에 담아서 한번에 전송하기 위해 만들어진 클래스, 객체 package JDBC03; public class BookDto { private int num; private String subject; private int makeyear; private int inprice; private int rentprice; private String grade; } 위 코드에서 마우스 우클릭 후 아래와 같이 Generate Getters and Setters... 클릭 아래와 같이 get, set 메서드가 생성됨 package JDBC03; public class BookDto { private int num; ..
-
[JDBC] 연습하기DataBase/JDBC 2022. 9. 9. 15:51
기존에 생성한 booklist를 이용(파일첨부) 1. select package JDBC02; import java.sql.Connection; import java.sql.DriverManager; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; public class BookSelect { public static void main(String[] args) { String url="jdbc:oracle:thin:@localhost:1521:xe"; Connection con=null; PreparedStatement pstmt=null; ResultSet rs=null; try { C..
-
[JDBC] select, insert, update, deleteDataBase/JDBC 2022. 9. 9. 15:47
select(조회) next() -최초 실행은 객체의 시작부분(데이터 없는곳)에서 첫번재 레코드로 이동하는 메서드. -그 다음 실행부터는 다음 레코드로 이동하는 명령이 됨. -이동하며 레코드를 rs라는 이름으로 액세스 함. getInt() -number형 필드값을 추출하는 메서드. -괄호 안에 필드이름을 정확히 써야함(필드명에 오타가 있거나 안 맞으면 부적합한 열이름 이라는 에러가 발생함) getString() -varchar2형(문자형) 필드값을 추출하는 메서드 -모든 자료형에 대해 get~() 메서드가 모두 존재함 import java.sql.Connection; import java.sql.DriverManager; import java.sql.PreparedStatement; import ..
-
[JDBC] Java Database ConnectivityDataBase/JDBC 2022. 9. 9. 15:42
자바프로그램 내에서 SQL문을 실행하기 위해 데이터 베이스를 연결해주는 API(application programming interface) Path 설정하기 데이터베이스 연결 -- SQL파일에 테이블 생성 create table customer( num number(3), name varchar2(10), email varchar2(20), tel varchar2(15) ); insert into customer values(1,'홍길동', 'abc1@abc.com', '010-1234-5234'); insert into customer values(2,'홍길서', 'abc2@abc.com', '010-2234-4234'); insert into customer values(3,'홍길남', 'abc3@..
-
[Oracle] join, view, subqueryDataBase/Oracle 2022. 9. 9. 15:39
JOIN -두개 이상의 테이블에 나눠져 있는 관련 데이터들을 하나의 테이블로 모아서 조회하고자 할 때 사용하는 명령 1. cross join -두개 이상의 테이블이 조인될 때 where 절에 의해 공통되는 컬럼에 의한 결합이 발생하지 않는 경우 create table testA( fieldA1 varchar2(10), fieldA2 varchar2(10), fieldA3 varchar2(10) ); insert into testA values('value11','value12','value13'); insert into testA values('value21','value22','value23'); insert into testA values('value31','value32','value33'); cr..