本文整理汇总了Java中java.sql.PreparedStatement.setBoolean方法的典型用法代码示例。如果您正苦于以下问题:Java PreparedStatement.setBoolean方法的具体用法?Java PreparedStatement.setBoolean怎么用?Java PreparedStatement.setBoolean使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.sql.PreparedStatement
的用法示例。
在下文中一共展示了PreparedStatement.setBoolean方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: updateStatement
import java.sql.PreparedStatement; //导入方法依赖的package包/类
void updateStatement(PreparedStatement statement, int parameterIndex, EvaluationContext ctx, Element elt) throws SQLException, ProcessingException {
switch (type) {
case BOOLEAN:
boolean b = evaluator.evaluateBoolean(ctx, elt);
statement.setBoolean(parameterIndex, b);
break;
case DOUBLE:
double d = evaluator.evaluateDouble(ctx, elt);
statement.setDouble(parameterIndex, d);
break;
case INT:
int i = evaluator.evaluateInt(ctx, elt);
statement.setInt(parameterIndex, i);
break;
case STRING:
String s = evaluator.evaluateString(ctx, elt);
statement.setString(parameterIndex, s);
break;
default:
throw new ProcessingException("unhandled type " + type);
}
}
示例2: getIndexInfo
import java.sql.PreparedStatement; //导入方法依赖的package包/类
/**
* Gets a description of a table's indices and statistics. They are
* ordered by NON_UNIQUE, TYPE, INDEX_NAME, and ORDINAL_POSITION.
*
*/
public ResultSet getIndexInfo(String catalog, String schema, String table, boolean unique, boolean approximate) throws SQLException
{
if (getCapitializeUsername() && schema != null) schema = schema.toUpperCase();
String query = (String)properties.get(PROP_INDEX_INFO_QUERY);
if (query != null) {
if (con != null) {
PreparedStatement stmt = con.prepareStatement(query);
stmt.setString(1, catalog);
stmt.setString(2, schema);
stmt.setString(3, table);
stmt.setBoolean(4, unique);
stmt.setBoolean(5, approximate);
return stmt.executeQuery();
} else throw new SQLException(bundle.getString("EXC_NoConnection")); // NOI18N
}
if (dmd == null) throw new SQLException(bundle.getString("EXC_NoDBMetadata")); // NOI18N
return dmd.getIndexInfo(catalog, schema, table, unique, approximate);
}
示例3: insertAccionDestinatario
import java.sql.PreparedStatement; //导入方法依赖的package包/类
public static boolean insertAccionDestinatario(AccionDestinatario destinatario, String usuarioResponsable){
try {
Connection conn=ConnectionConfiguration.conectar();
String query = " insert into accion_destinatario (cantidad, descripcion, version, borrado, beneficiario_tipo_id, accion_id, beneficiario_grupo_id, usuario_responsable)"
+ " values (?, ?, ?, ?, ?, ?, ?, ?)";
PreparedStatement insert = conn.prepareStatement(query);
insert.setInt (1, destinatario.getCantidad());
insert.setString (2, destinatario.getDescripcion());
insert.setInt (3, destinatario.getVersion());
insert.setBoolean (4, destinatario.isBorrado());
insert.setInt (5, destinatario.getBeneficiarioTipoId());
insert.setInt (6, destinatario.getAccionId());
insert.setInt (7, destinatario.getBeneficiarioGrupoId());
insert.setString (8, usuarioResponsable);
insert.execute();
conn.close();
return true;
} catch (SQLException e) {e.printStackTrace(); return false;}
}
示例4: insertValuesIntoStatement
import java.sql.PreparedStatement; //导入方法依赖的package包/类
@Override
public PreparedStatement insertValuesIntoStatement(PreparedStatement statement, String[] values, String[] valueTypes, int offset) throws NumberFormatException, SQLException {
for (int i = 0; i < values.length; i++) {
String valueType = valueTypes[i + offset].toLowerCase();
if ((values[i] == null) || (values[i].equals(""))) {
if (valueType.contains("long") || valueType.contains("big") || valueType.contains("int8"))
statement.setNull(i + 1, java.sql.Types.BIGINT);
else if (valueType.contains("int") || valueType.contains("serial"))
statement.setNull(i + 1, java.sql.Types.INTEGER);
else if (valueType.contains("float") || valueType.contains("numeric") || valueType.contains("decimal") || valueType.contains("real") || valueType.contains("precision"))
statement.setNull(i + 1, java.sql.Types.FLOAT);
else if (valueType.contains("bool"))
statement.setNull(i + 1, java.sql.Types.BOOLEAN);
else if (valueType.contains("date"))
statement.setNull(i + 1, java.sql.Types.DATE);
else
statement.setNull(i + 1, java.sql.Types.VARCHAR);
}
else {
if (valueType.contains("long") || valueType.contains("big") || valueType.contains("int8"))
statement.setLong(i + 1, Long.valueOf(values[i]).longValue());
else if (valueType.contains("int") || valueType.contains("serial"))
statement.setInt(i + 1, Integer.valueOf(values[i]).intValue());
else if (valueType.contains("float") || valueType.contains("numeric") || valueType.contains("decimal") || valueType.contains("real") || valueType.contains("precision"))
statement.setFloat(i + 1, Float.valueOf(values[i]).shortValue());
else if (valueType.contains("bool"))
statement.setBoolean(i + 1, Boolean.valueOf(values[i]).booleanValue());
else if (valueType.contains("date"))
statement.setDate(i + 1, Date.valueOf(values[i]));
else
statement.setString(i + 1, values[i]);
}
}
return statement;
}
开发者ID:HPI-Information-Systems,项目名称:AdvancedDataProfilingSeminar,代码行数:37,代码来源:PostgreSQLDataAccessObject.java
示例5: addGroupVisibility
import java.sql.PreparedStatement; //导入方法依赖的package包/类
@Override
public void addGroupVisibility(Connection txn, ContactId c, GroupId g,
boolean shared) throws DbException {
PreparedStatement ps = null;
try {
String sql = "INSERT INTO groupVisibilities"
+ " (contactId, groupId, shared)"
+ " VALUES (?, ?, ?)";
ps = txn.prepareStatement(sql);
ps.setInt(1, c.getInt());
ps.setBytes(2, g.getBytes());
ps.setBoolean(3, shared);
int affected = ps.executeUpdate();
if (affected != 1) throw new DbStateException();
ps.close();
} catch (SQLException e) {
tryToClose(ps);
throw new DbException(e);
}
}
示例6: setGroupVisibility
import java.sql.PreparedStatement; //导入方法依赖的package包/类
@Override
public void setGroupVisibility(Connection txn, ContactId c, GroupId g,
boolean shared) throws DbException {
PreparedStatement ps = null;
try {
String sql = "UPDATE groupVisibilities SET shared = ?"
+ " WHERE contactId = ? AND groupId = ?";
ps = txn.prepareStatement(sql);
ps.setBoolean(1, shared);
ps.setInt(2, c.getInt());
ps.setBytes(3, g.getBytes());
int affected = ps.executeUpdate();
if (affected < 0 || affected > 1) throw new DbStateException();
ps.close();
} catch (SQLException e) {
tryToClose(ps);
throw new DbException(e);
}
}
示例7: appendValue
import java.sql.PreparedStatement; //导入方法依赖的package包/类
public void appendValue(PreparedStatement statement, int index) throws SQLException {
index = index + 1;
if (dataType == DataType.BOOLEAN) {
statement.setBoolean(index, dataValue.equals("1"));
} else if (dataType == DataType.INTEGER) {
statement.setInt(index, Integer.parseInt(dataValue));
} else if (dataType == DataType.STRING) {
statement.setString(index, dataValue);
} else if (dataType == DataType.DOUBLE) {
statement.setDouble(index, Double.parseDouble(dataValue));
} else if (dataType == DataType.FLOAT) {
statement.setFloat(index, Float.parseFloat(dataValue));
} else if (dataType == DataType.LONG) {
statement.setLong(index, Long.parseLong(dataValue));
}
}
示例8: insertLineaEstrategica
import java.sql.PreparedStatement; //导入方法依赖的package包/类
public static void insertLineaEstrategica(LineaEstrategica lineaEstrategica, String usuarioResponsable){
try {
Connection conn=ConnectionConfiguration.conectar();
String query = " insert into linea_estrategica (nombre,descripcion,orden,borrado, usuario_responsable)"
+ " values (?, ?, ?, ?, ?)";
PreparedStatement insert = conn.prepareStatement(query);
//insert.setInt (1, lineaEstrategica.getId());
insert.setString (1, lineaEstrategica.getNombre());
insert.setString (2, lineaEstrategica.getDescripcion());
insert.setInt (3, lineaEstrategica.getOrden());
insert.setBoolean (4, lineaEstrategica.isBorrado());
insert.setString (5, usuarioResponsable);
insert.execute();
conn.close();
} catch (SQLException e) {e.printStackTrace();}
}
示例9: insertAccionHasEtiqueta
import java.sql.PreparedStatement; //导入方法依赖的package包/类
public static void insertAccionHasEtiqueta(AccionHasEtiqueta accionHasEtiqueta, String usuarioResponsable){
try {
Connection conn=ConnectionConfiguration.conectar();
String query = " insert into accion_has_etiqueta (accion_id, etiqueta_id, proporcion,borrado, usuario_responsable)"
+ " values (?, ?, ?, ?, ?)";
PreparedStatement insert = conn.prepareStatement(query);
insert.setInt (1, accionHasEtiqueta.getAccionId());
insert.setInt (2, accionHasEtiqueta.getEtiquetaId());
insert.setInt (3, accionHasEtiqueta.getProporcion());
insert.setBoolean (4, accionHasEtiqueta.isBorrado());
insert.setString (5, usuarioResponsable);
insert.execute();
conn.close();
} catch (SQLException e) {e.printStackTrace();}
}
示例10: insertInsLineaAccion
import java.sql.PreparedStatement; //导入方法依赖的package包/类
public static boolean insertInsLineaAccion(InsLineaAccion insLineaAccion, String usuarioResponsable){
try {
Connection conn=ConnectionConfiguration.conectar();
String query = " insert into ins_linea_accion (linea_accion_id, institucion_id, periodo_id, meta, version, borrado, usuario_responsable)"
+ " values (?, ?, ?, ?, ?, ?, ?)";
PreparedStatement insert = conn.prepareStatement(query);
//insert.setInt (1, insLineaAccion.getId());
insert.setInt (1, insLineaAccion.getLineaAccionId());
insert.setInt (2, insLineaAccion.getInstitucionId());
insert.setInt (3, insLineaAccion.getPeriodoId());
insert.setDouble (4, insLineaAccion.getMeta());
insert.setInt(5, insLineaAccion.getVersion());
insert.setBoolean (6, insLineaAccion.isBorrado());
insert.setString(7, usuarioResponsable);
insert.execute();
conn.close();
return true;
} catch (SQLException e) {e.printStackTrace();return false;}
}
示例11: insertRowInTest
import java.sql.PreparedStatement; //导入方法依赖的package包/类
private void insertRowInTest(long id) throws SQLException
{
PreparedStatement ps = connection.prepareStatement(
"INSERT INTO TEST (ID, UUID, ACTIVE, AMOUNT, DESCRIPTION, CREATED_DATE, LAST_UPDATED) VALUES (?, ?, ?, ?, ?, ?, ?)");
ps.setLong(1, id);
ps.setBytes(2, "FOO".getBytes());
ps.setBoolean(3, true);
ps.setDouble(4, 50d);
ps.setString(5, "BAR");
ps.setDate(6, new Date(1000l));
ps.setTimestamp(7, new Timestamp(5000l));
ps.executeUpdate();
}
示例12: borradoInstitucion
import java.sql.PreparedStatement; //导入方法依赖的package包/类
public static boolean borradoInstitucion(Institucion objeto,
String usuarioResponsable) {
try {
Connection conect = ConnectionConfiguration.conectar();
String query = "update Institucion set ";
PreparedStatement update = null;
objeto.changeBorrado();
query += " borrado = ?,";
query += " usuario_responsable = ?,";
query = query.substring(0, query.length() - 1);
query += " where id = ? ";
int cantCampos = 0;
update = conect.prepareStatement(query);
cantCampos++;
update.setBoolean(cantCampos, objeto.isBorrado());
cantCampos++;
update.setString(cantCampos, usuarioResponsable);
cantCampos++;
update.setInt(cantCampos, objeto.getId());
update.execute();
conect.close();
return true;
} catch (SQLException e) {
e.printStackTrace();
return false;
}
}
示例13: testBooleanComplex
import java.sql.PreparedStatement; //导入方法依赖的package包/类
public void testBooleanComplex() {
PreparedStatement ps = null;
ResultSet rs = null;
try {
ps = netConn.prepareStatement(
"INSERT INTO alltypes(id, b) VALUES(?, ?)");
ps.setInt(1, 3);
ps.setBoolean(2, false);
assertEquals(1, ps.executeUpdate());
ps.setInt(1, 4);
assertEquals(1, ps.executeUpdate());
ps.close();
netConn.commit();
ps = netConn.prepareStatement(
"SELECT * FROM alltypes WHERE b = ?");
ps.setBoolean(1, false);
rs = ps.executeQuery();
assertTrue("Got no rows with b = false", rs.next());
assertEquals(Boolean.class, rs.getObject("b").getClass());
assertTrue("Got only one row with b = false", rs.next());
assertEquals(false, rs.getBoolean("b"));
assertFalse("Got too many rows with b = false", rs.next());
} catch (SQLException se) {
junit.framework.AssertionFailedError ase
= new junit.framework.AssertionFailedError(se.getMessage());
ase.initCause(se);
throw ase;
} finally {
try {
if (rs != null) {
rs.close();
}
if (ps != null) {
ps.close();
}
} catch(Exception e) {
}
}
}
示例14: insertActividad
import java.sql.PreparedStatement; //导入方法依赖的package包/类
public static void insertActividad(Cronograma actividad, String usuarioResponsable){
try {
Connection conn=ConnectionConfiguration.conectar();
String query = " insert into actividad (nombre,descripcion,proporcion,peso,version,borrado,accion_id,unidad_medida_id,hito_tipo_id,acumulable, usuario_responsable, prod_concat)"
+ " values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
PreparedStatement insert = conn.prepareStatement(query);
insert.setString (1, actividad.getNombre());
insert.setString (2, actividad.getDescripcion());
insert.setDouble (3, actividad.getProporcion());
insert.setDouble (4, actividad.getPeso());
insert.setInt (5, actividad.getVersion());
insert.setBoolean (6, actividad.isBorrado());
insert.setInt (7, actividad.getAccion_id());
insert.setInt (8, actividad.getUnidad_medida_id());
insert.setInt (9, actividad.getHito_tipo_id());
insert.setBoolean(10, actividad.isAcumulable());
insert.setString (11, usuarioResponsable);
insert.setString(12, actividad.getProdConcat());
insert.execute();
conn.close();
} catch (SQLException e) {e.printStackTrace();}
}
示例15: getField
import java.sql.PreparedStatement; //导入方法依赖的package包/类
@Override
public void getField(final PreparedStatement ps, final int idx) throws SQLException
{
if (value == null)
ps.setNull(idx, Types.BOOLEAN);
else
ps.setBoolean(idx, value);
}