当前位置: 首页>>代码示例>>Java>>正文


Java Statement.executeUpdate方法代码示例

本文整理汇总了Java中java.sql.Statement.executeUpdate方法的典型用法代码示例。如果您正苦于以下问题:Java Statement.executeUpdate方法的具体用法?Java Statement.executeUpdate怎么用?Java Statement.executeUpdate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.sql.Statement的用法示例。


在下文中一共展示了Statement.executeUpdate方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: updateUserId

import java.sql.Statement; //导入方法依赖的package包/类
void updateUserId() throws FileNotFoundException, IOException, SQLException {
    String adminUserId = getProperty(ssoPropertyFile, ADMIN_USER_ID);
    Connection conn = null;
    Statement stmt = null;
    try {
        conn = getConnetion();
        stmt = conn.createStatement();
        stmt.executeUpdate(String.format(
                "UPDATE %s SET userid = '%s' WHERE tkey = 1000",
                TABLE_NAME, adminUserId));
        stmt.close();
        conn.close();

    } finally {
        closeStatement(stmt);
        closeConnection(conn);

    }
}
 
开发者ID:servicecatalog,项目名称:oscm,代码行数:20,代码来源:SSOPropertyImport.java

示例2: initInbox

import java.sql.Statement; //导入方法依赖的package包/类
private void initInbox() throws SQLException, ClassNotFoundException {
    String sql1 = "DROP TABLE IF EXISTS inbox";
    String sql2 = "CREATE TABLE inbox " +
            "(msgId Varchar(100) NOT NULL, " +
            "threadId Varchar(100) NOT NULL, " +
            "historyId Varchar(100) NOT NULL, " +
            "sentTo VARCHAR(1000) NOT NULL, " +
            "recievedFrom Varchar(1000) NOT NULL, " +
            "mailDate Varchar(1000) NOT NULL," +
            "subject Varchar(10000) , " +
            "isUnread int NOT NULL);";
    Statement statement = h2DBConnection.getConnection().createStatement();
    statement.executeUpdate(sql1);
    statement.executeUpdate(sql2);
    statement.close();
}
 
开发者ID:ashoknailwal,项目名称:desktop-gmail-client,代码行数:17,代码来源:InitDbTables.java

示例3: dropExistingSchema

import java.sql.Statement; //导入方法依赖的package包/类
/**
 * Delete any existing tables.
 */
public void dropExistingSchema() throws SQLException {
  ConnManager mgr = getManager();
  String [] tables = mgr.listTables();
  if (null != tables) {
    Connection conn = mgr.getConnection();
    for (String table : tables) {
      Statement s = conn.createStatement();
      try {
        s.executeUpdate("DROP TABLE \"" + table + "\"");
        conn.commit();
      } finally {
        s.close();
      }
    }
  }
}
 
开发者ID:aliyun,项目名称:aliyun-maxcompute-data-collectors,代码行数:20,代码来源:HsqldbTestServer.java

示例4: AgregarEspecialidad

import java.sql.Statement; //导入方法依赖的package包/类
public String AgregarEspecialidad(String cod, String especialidad) {
    Conexion nconexion = new Conexion();  //objeto de la clase conexion
    Connection conex; 
   
    try
    {
        nconexion.Conectar(); // ejecuta el metodo conectar de la clase conexion el que contiene la direccion de la base de datos 
        conex = nconexion.getConexion();  //aca se retorna la conexion que se obtuvo
        Statement comando = conex.createStatement(); //comando para poder ejecutar executeUpdate
        
        //EJECUTAR LA CONSULTA DE INSERCION
        
        comando.executeUpdate("insert into especialidades() values('0','"+cod+"','"+especialidad+"')");

        conex.close();
        return "Especialidad agregada exitosamente";
    
    }
    
    catch(Exception e)
    {
        
        return "Ha ocurrido un error al agregar una especialidad "+e;
    }

}
 
开发者ID:JuanJoseFJ,项目名称:ProyectoPacientes,代码行数:27,代码来源:AsignarEsp.java

示例5: executeUpdate

import java.sql.Statement; //导入方法依赖的package包/类
public final int executeUpdate(String sql, Object... args) {
    if (!isConnected()) {
        return -1;
    }
    String temp = null;
    try {
        temp = (args != null && args.length != 0) ? String.format(sql, args) : sql;
        if (DEBUG_SQL) {
            System.out.println(temp);
        }
        final Statement statement = createStatement();
        final int result = statement.executeUpdate(temp);
        statement.close();
        return result;
    } catch (Exception ex) {
        System.err.println("Database: Executing update error");
        if (DEBUG) {
            System.err.println("SQL: " + temp);
        }
        ex.printStackTrace();
        return -1;
    }
}
 
开发者ID:Panzer1119,项目名称:Supreme-Bot,代码行数:24,代码来源:Database.java

示例6: manualTestBug22750465SomeReadWriteOperations

import java.sql.Statement; //导入方法依赖的package包/类
private void manualTestBug22750465SomeReadWriteOperations(Connection testConn) throws Exception {
    Statement stmt = testConn.createStatement();
    try {
        stmt.executeUpdate("CREATE TABLE IF NOT EXISTS testBug22750465 (id INT)");
        stmt.executeUpdate("INSERT INTO testBug22750465 VALUES (1)");
        ResultSet rs = stmt.executeQuery("SELECT * FROM testBug22750465");
        assertTrue(rs.next());
    } finally {
        stmt.executeUpdate("DROP TABLE IF EXISTS testBug22750465");
        stmt.close();
    }
}
 
开发者ID:Jugendhackt,项目名称:OpenVertretung,代码行数:13,代码来源:TestRegressions.java

示例7: upgrade

import java.sql.Statement; //导入方法依赖的package包/类
/**
 * Perform upgrade.
 */
public void upgrade(final Connection conn, final int upgradeToVersion) throws SQLException {
  final boolean savedAutoCommit = conn.getAutoCommit();
  Statement st = null; // NOPMD
  PreparedStatement pstmt = null; // NOPMD
  try {
    // create statement
    conn.setAutoCommit(true);
    st = conn.createStatement();

    log.debug("Updating version");
    st.executeUpdate("update SYSTEM_PROPERTY set VALUE = '" + upgraderVersion() + "' where NAME = 'parabuild.schema.version' ");

    // finish
    conn.commit();

    // request post-startup config manager action
    System.setProperty(SystemConstants.SYSTEM_PROPERTY_INIT_ADVANCED_SETTINGS, "true");
  } finally {
    IoUtils.closeHard(pstmt);
    IoUtils.closeHard(st);
    conn.setAutoCommit(savedAutoCommit);
  }
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:27,代码来源:UpgraderToVersion17.java

示例8: populateTable

import java.sql.Statement; //导入方法依赖的package包/类
private void populateTable(String tableName) throws SQLException {
  Statement statement = conn.createStatement();
  try {
    statement.executeUpdate("INSERT INTO " + tableName
        + " VALUES(1,'Aaron','2009-05-14',1000000.00,TRUE,'engineering')");
    statement.executeUpdate("INSERT INTO " + tableName
        + " VALUES(2,'Bob','2009-04-20',400.00,TRUE,'sales')");
    statement.executeUpdate("INSERT INTO " + tableName
        + " VALUES(3,'Fred','2009-01-23',15.00,FALSE,'marketing')");
    conn.commit();
  } finally {
    statement.close();
  }
}
 
开发者ID:aliyun,项目名称:aliyun-maxcompute-data-collectors,代码行数:15,代码来源:NetezzaImportManualTest.java

示例9: setUp

import java.sql.Statement; //导入方法依赖的package包/类
@Override
public void setUp() throws Exception {
    if (this.isSetForFabricTest) {
        this.conn = (FabricMySQLConnection) this.ds.getConnection(this.username, this.password);

        // create table globally
        this.conn.setServerGroupName("fabric_test1_global");
        Statement stmt = this.conn.createStatement();
        stmt.executeUpdate("drop table if exists employees");
        stmt.executeUpdate("create table employees (emp_no INT PRIMARY KEY, first_name CHAR(40), last_name CHAR(40))");
        this.conn.clearServerSelectionCriteria();
    }
}
 
开发者ID:Jugendhackt,项目名称:OpenVertretung,代码行数:14,代码来源:TestHashSharding.java

示例10: deleteXBRecord

import java.sql.Statement; //导入方法依赖的package包/类
/**
 * This method demonstrates the bug in cascading deletes. Before this method,
 * the CA table has 12 records. After, it should have 9, but instead it has
 * 0.
 */
private static void deleteXBRecord(Connection con) throws SQLException {

    Statement stmt = con.createStatement();

    stmt.executeUpdate(
        "DELETE FROM XB WHERE LSACONXB = 'LEAA' AND EIACODXA = 'T850' AND LCNTYPXB = 'P' AND ALTLCNXB = '00'");
    stmt.close();
}
 
开发者ID:Julien35,项目名称:dev-courses,代码行数:14,代码来源:TestCascade.java

示例11: testRefreshTable

import java.sql.Statement; //导入方法依赖的package包/类
public void testRefreshTable() throws Exception {
    Table fooTable = metadata.getDefaultSchema().getTable("FOO");
    assertNames(Arrays.asList("ID", "FOO_NAME"), fooTable.getColumns());
    Statement stmt = conn.createStatement();
    stmt.executeUpdate("ALTER TABLE FOO ADD NEW_COLUMN VARCHAR(16)");
    stmt.close();
    fooTable.refresh();
    assertNames(Arrays.asList("ID", "FOO_NAME", "NEW_COLUMN"), fooTable.getColumns());
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:10,代码来源:JDBCMetadataDerbyTest.java

示例12: sendFileName

import java.sql.Statement; //导入方法依赖的package包/类
public boolean sendFileName(String newName, String zipName) throws SQLException{
	Statement st = connection.createStatement();
	int response;
	String sql = ("UPDATE CTP "
			+ "SET zipName = " + "\"" + zipName + "\"" 
			+ " WHERE nameAnon = " + "\"" + newName + "\""
			+ ";");
	response = st.executeUpdate(sql);		
	return response > 0;
}
 
开发者ID:anousv,项目名称:OrthancAnonymization,代码行数:11,代码来源:JDBCConnector.java

示例13: setTotalPlaytime

import java.sql.Statement; //导入方法依赖的package包/类
public void setTotalPlaytime(String timePlayed, String titleID){
	try{
		Statement stmt = connection.createStatement(); 
		stmt.executeUpdate("UPDATE local_roms SET timePlayed='"+timePlayed+"' WHERE titleID = '"+titleID+"';");
		connection.commit();
		stmt.close();
	}catch(SQLException e){
		LOGGER.error("failed to set total play time", e);
		e.printStackTrace();
	}
}
 
开发者ID:Seil0,项目名称:cemu_UI,代码行数:12,代码来源:DBController.java

示例14: testBug37570

import java.sql.Statement; //导入方法依赖的package包/类
public void testBug37570() throws Exception {
    Properties props = new Properties();
    props.setProperty("characterEncoding", "utf-8");
    props.setProperty("passwordCharacterEncoding", "utf-8");

    // TODO enable for usual connection?
    Connection adminConn = getAdminConnectionWithProps(props);

    if (adminConn != null) {

        String unicodePassword = "\u0430\u0431\u0432"; // Cyrillic string
        String user = "bug37570";
        Statement adminStmt = adminConn.createStatement();

        adminStmt.executeUpdate("create user '" + user + "'@'127.0.0.1' identified by 'foo'");
        adminStmt.executeUpdate("grant usage on *.* to '" + user + "'@'127.0.0.1'");
        adminStmt.executeUpdate("update mysql.user set password=PASSWORD('" + unicodePassword + "') where user = '" + user + "'");
        adminStmt.executeUpdate("flush privileges");

        try {
            ((MySQLConnection) adminConn).changeUser(user, unicodePassword);
        } catch (SQLException sqle) {
            assertTrue("Connection with non-latin1 password failed", false);
        }

    }
}
 
开发者ID:rafallis,项目名称:BibliotecaPS,代码行数:28,代码来源:ConnectionRegressionTest.java

示例15: deleteAllGames

import java.sql.Statement; //导入方法依赖的package包/类
/**
*Method to delete all games
*
*@throws SQLException if no database connection is found or another error occurs
*/
@Override
public void deleteAllGames() throws SQLException{
  Connection connection = DB.openConnection();
  Statement s = connection.createStatement();
  s.executeUpdate(DELETE_ALL);
  s.close();
  connection.close();
}
 
开发者ID:StefanoMartella,项目名称:GamingPlatform,代码行数:14,代码来源:GiocoDao.java


注:本文中的java.sql.Statement.executeUpdate方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。