
org.eweb4j.orm.dao.insert.InsertDAOImpl Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of eweb4j-all Show documentation
Show all versions of eweb4j-all Show documentation
easy web framework for java, full-stack
The newest version!
package org.eweb4j.orm.dao.insert;
import java.sql.Connection;
import java.util.ArrayList;
import java.util.List;
import javax.sql.DataSource;
import org.eweb4j.orm.dao.DAOException;
import org.eweb4j.orm.jdbc.JdbcUtil;
import org.eweb4j.orm.sql.Sql;
import org.eweb4j.orm.sql.SqlFactory;
public class InsertDAOImpl implements InsertDAO {
private DataSource ds;
private String dbType;
public InsertDAOImpl(DataSource ds, String dbType) {
this.ds = ds;
this.dbType = dbType;
}
public Number[] batchInsert(T[] ts, String... fields) throws DAOException {
Number[] ids = null;
Connection con = null;
if (ts == null || ts.length == 0)
return ids;
try {
con = ds.getConnection();
Sql[] sqls = null;
if (fields != null && fields.length > 0)
sqls = SqlFactory.getInsertSql(ts).createByFields(fields);
else
sqls = SqlFactory.getInsertSql(ts).create();
List
© 2015 - 2025 Weber Informatics LLC | Privacy Policy