Code example for PreparedStatement

Methods: executeUpdatesetBlobsetLongsetString

0
Connection conn = dao.getBootstrapConn().getDBConn();
			  String st = "insert into tab_" + srcId + "(id, scn, srckey, val) values(?, ?, ?, ?)";
			  System.out.println("SQL :" + st);
			  stmt = conn.prepareStatement(st);
			  stmt.setLong(1,rId);
			  stmt.setLong(2,scn);
			  stmt.setString(3, srcKey);
			  stmt.setBlob(4, new ByteArrayInputStream(data.getBytes()));
			  stmt.executeUpdate();
		  } catch ( Exception ex) {
			  System.err.println("Exception :" + ex);
			  throw new RuntimeException(ex);
		  } finally { 
			  DBHelper.close(stmt);
		  } 
	  } 
	  @Test 
	  public void testBootstrapService() 
	              throws InstantiationException, IllegalAccessException, ClassNotFoundException, 
Stop searching for code, let great code find you!  Add Codota to your java IDE