database.sarang.net
UserID
Passwd
Database
DBMS
ㆍMySQL
PostgreSQL
Firebird
Oracle
Informix
Sybase
MS-SQL
DB2
Cache
CUBRID
LDAP
ALTIBASE
Tibero
DB 문서들
스터디
Community
공지사항
자유게시판
구인|구직
DSN 갤러리
도움주신분들
Admin
운영게시판
최근게시물
MySQL Q&A 27328 게시물 읽기
No. 27328
Multiple Statements with MySQL and JDBC
작성자
zican
작성일
2008-01-16 17:48ⓒ
2008-01-16 17:51ⓜ
조회수
5,222

ibatis를 이용해서 dao를 만들고 있는데 ibatis의 insert나 select update할때 한번에 한개의 query 밖에 쓰지 못해서 stored procedure로 만들어야 고민고민중이었는데 검색해보니 jdbc 드라이버에서 옵션설정을 하면 한번에 여러개의 쿼리를 보낼 수 있다는군요 ; 를 구분자로 씁니다.

mysql은 보안문제로 allowMultiQueries 디폴트 false값을 갖게 했다고 합니다. 
(sql injection attack 방지)
ibatis처럼 바인딩해서 주로 쓰는 경우는 문제가 좀 덜하지 않을까 싶습니다. 
( $sql$ 이런거 쓰실때는 주의 )


mysql jdbc 드라이버 속성 설정
http://dev.mysql.com/doc/refman/5.0/en/connector-j-reference-configuration-properties.html

allowMultiQueries Allow the use of ';' to delimit multiple queries during one statement (true/false), defaults to 'false' false 3.1.1 

찾은 원문 내용들입니다.

Multiple Statements with MySQL and JDBC
url : http://www.petefreitag.com/item/357.cfm

Cameron Childress pointed out the allowMultiQueries setting in the MySQL JDBC driver on the CFGURU list.
It is set to false by default to protect you from SQL Injection attacks.
When set to true MySQL will allow multiple SQL statements (seperated by a semi-colon) to be executed in a single CFQUERY tag.
If you need to run multiple statements in a single CFQUERY,
Dave Watts suggested creating another datasource with this setting turned on, which is only to be used when your running multiple statements.

But don't let this stop you from using prepared statements with CFQUERYPARAM,
just because MySQL is safe by default - it is still a best practice, adds performance and type safety.

[Top]
No.
제목
작성자
작성일
조회
27332쿼리가 안됩니다.ㅜㅜ
김현옥
2008-01-17
2523
27330데이터베이스를 검색 할 때요
tragic
2008-01-17
2727
27329외래키생성시 에러가 나는데 원인을 못 찾겠습니다. 도와주세요. [1]
궁금이
2008-01-17
2804
27328Multiple Statements with MySQL and JDBC
zican
2008-01-16
5222
27327replication 에서 Master 테이블만 truncate하는 법 [2]
박성원
2008-01-16
2941
27326query timeout설정
dba
2008-01-15
2635
27325프로세서 갯수
김준형
2008-01-15
2857
Valid XHTML 1.0!
All about the DATABASE... Copyleft 1999-2024 DSN, All rights reserved.
작업시간: 0.019초, 이곳 서비스는
	PostgreSQL v16.2로 자료를 관리합니다