當前位置: 首頁>>代碼示例>>Java>>正文


Java Statement.close方法代碼示例

本文整理匯總了Java中com.mysql.jdbc.Statement.close方法的典型用法代碼示例。如果您正苦於以下問題:Java Statement.close方法的具體用法?Java Statement.close怎麽用?Java Statement.close使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.mysql.jdbc.Statement的用法示例。


在下文中一共展示了Statement.close方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: doFindAllChanged

import com.mysql.jdbc.Statement; //導入方法依賴的package包/類
@Override
/**
 * 
 * @Title: doFindAllChanged
 * @Description: ͨ查找所有更新了Delta的Content,返回Content的LinkedList
 * @return LinkedList<Content>
 * @throws Exception
 */
public LinkedList<Content> doFindAllChanged() throws Exception{
	String query = "select * from Content where Delta!=\"\"";
	Statement stat = (Statement) conn.createStatement();
	ResultSet rs = stat.executeQuery(query);
	LinkedList<Content> result = new LinkedList<Content>();
	while(rs.next()){
		Content newContent = new Content();
		newContent.setContentID(rs.getInt(1));
		newContent.setUrlID(rs.getInt(2));
		newContent.setHtml(rs.getString(3));
		newContent.setDelta(rs.getString(4));
		result.add(newContent);
	}
	rs.close();stat.close();		
	return result;
}
 
開發者ID:wrayzheng,項目名稱:webpage-update-subscribe,代碼行數:25,代碼來源:ContentDAO.java

示例2: doFindAllEnabledAndRealTimePush

import com.mysql.jdbc.Statement; //導入方法依賴的package包/類
@Override
/**
 * 
 * @Title: doFindAllEnabledAndRealTimePush
 * @Description: 發現所有激活狀態同時是實時推送的Url
 * @return Map<Integer, String>
 * @throws SQLException
 */
public Map<Integer, String> doFindAllEnabledAndRealTimePush() throws SQLException {
	String query = "select UrlID,UserName from Url where Enabled=true and RealTimePush=true";
	Statement stat = (Statement) conn.createStatement();
	ResultSet rs = stat.executeQuery(query);
	Map<Integer,String> urlMap= new HashMap<Integer,String>();
	while(rs.next()){
		int UrlID = rs.getInt(1);
		String UserName = rs.getString(2);
		urlMap.put(UrlID, UserName);
	}
	rs.close();stat.close();
	return urlMap;
}
 
開發者ID:wrayzheng,項目名稱:webpage-update-subscribe,代碼行數:22,代碼來源:UrlDAO.java

示例3: doFindAllEnabledAndNotRealTimePush

import com.mysql.jdbc.Statement; //導入方法依賴的package包/類
@Override
/**
 * 
 * @Title: doFindAllEnabledAndNotRealTimePush
 * @Description: 發現所有不處於激活狀態同時是實時推送的Url
 * @return Map<Integer, String>
 * @throws SQLException
 */
public Map<Integer, String> doFindAllEnabledAndNotRealTimePush() throws SQLException {
	String query = "select UrlID,UserName from Url where Enabled=true and RealTimePush=false";
	Statement stat = (Statement) conn.createStatement();
	ResultSet rs = stat.executeQuery(query);
	Map<Integer,String> urlMap= new HashMap<Integer,String>();
	while(rs.next()){
		int UrlID = rs.getInt(1);
		String UserName = rs.getString(2);
		urlMap.put(UrlID, UserName);
	}
	rs.close();stat.close();
	return urlMap;
}
 
開發者ID:wrayzheng,項目名稱:webpage-update-subscribe,代碼行數:22,代碼來源:UrlDAO.java

示例4: getAllUrl

import com.mysql.jdbc.Statement; //導入方法依賴的package包/類
@Override
/**
 * 
 * @Title: getAllUrl
 * @Description: ����Url��������������UrlID�Ͷ�ӦUrl��
 * @return Map<Integer,String>
 * @throws SQLException
 */
public Map<Integer,String> getAllUrl() throws SQLException {
	String query = "select UrlID,Url from Url where Enabled=true";
	Statement stat = (Statement) conn.createStatement();
	ResultSet rs = stat.executeQuery(query);
	Map<Integer,String> urlMap= new HashMap<Integer,String>();
	while(rs.next()){
		int UrlID = rs.getInt(1);
		String Url = rs.getString(2);
		urlMap.put(UrlID, Url);
	}
	rs.close();stat.close();
	return urlMap;
}
 
開發者ID:wrayzheng,項目名稱:webpage-update-subscribe,代碼行數:22,代碼來源:UrlDAO.java

示例5: getSqlExecuteUpdate

import com.mysql.jdbc.Statement; //導入方法依賴的package包/類
/**
 * This Method executes a SQL-Statement (Create, Insert, Update) in
 * the database and returns true if this was successful 
 * @param sqlStatement the SQL-Statement to execute
 * @return True, if the execution was successful
 */
public boolean getSqlExecuteUpdate(String sqlStatement) {
	
	boolean successfull = false;
	Statement state = null;
	try {
		state = getNewStatement();
		state.executeUpdate(sqlStatement);
		successfull = true;
		
	} catch (SQLException e) {
		//e.printStackTrace();
		String msg = e.getLocalizedMessage() + newLine;
		msg += sqlStatement;
		this.dbError.setText(msg);
		this.dbError.put2Clipboard(sqlStatement);
		this.dbError.setErrNumber( e.getErrorCode() );
		this.dbError.setHead( "Fehler bei der Ausführung von 'executeUpdate'!" );
		this.dbError.setErr(true);
		this.dbError.show();
		
	} finally {
		try {
			if (state!=null) state.close();
		} catch (SQLException sqle) {
			sqle.printStackTrace();
		}
	}
	return successfull;
}
 
開發者ID:EnFlexIT,項目名稱:AgentWorkbench,代碼行數:36,代碼來源:DBConnection.java

示例6: executeQuery

import com.mysql.jdbc.Statement; //導入方法依賴的package包/類
public Table executeQuery(String query) throws SQLException {
	Table ret;

	Statement stmt = conn.createStatement();
	// stmt.setEscapeProcessing( true );
	ResultSet rset = stmt.executeQuery(query);
	ret = getResults(rset);
	rset.close();
	stmt.close();
	return (ret);
}
 
開發者ID:pinfake,項目名稱:pes6j,代碼行數:12,代碼來源:Db.java

示例7: executeUpdate

import com.mysql.jdbc.Statement; //導入方法依賴的package包/類
public int executeUpdate(String query) throws SQLException {
	int ret = 0;
	Statement stmt = conn.createStatement();
	stmt.setEscapeProcessing(true);
	stmt.executeUpdate(query);
	ResultSet tmp = stmt.getGeneratedKeys();
	if (tmp.next()) {
		// Retrieve the auto generated key(s).
		ret = tmp.getInt(1);
	}
	stmt.close();
	return ret;
}
 
開發者ID:pinfake,項目名稱:pes6j,代碼行數:14,代碼來源:Db.java

示例8: flushBacklogInternal

import com.mysql.jdbc.Statement; //導入方法依賴的package包/類
/**
 * Flush the backlog (nodeBacklog and tripleBacklog) to the database; needs to be implemented by subclasses.
 *
 * @throws java.sql.SQLException
 */
@Override
protected void flushBacklogInternal() throws SQLException {
    try {
        // load node backlog
        Statement statement = (com.mysql.jdbc.Statement)connection.getJDBCConnection().createStatement();
        statement.setLocalInfileInputStream(MySQLLoadUtil.flushNodes(nodeBacklog));
        statement.execute(
                "LOAD DATA LOCAL INFILE 'nodes.csv' " +
                        "INTO TABLE nodes " +
                        "COLUMNS TERMINATED BY ',' " +
                        "OPTIONALLY ENCLOSED BY '\"' " +
                        "ESCAPED BY '\"' " +
                        "LINES TERMINATED BY '\\r\\n' " +
                        "(id,ntype,svalue,dvalue,ivalue,tvalue,bvalue,ltype,lang,createdAt)");


        statement.setLocalInfileInputStream(MySQLLoadUtil.flushTriples(tripleBacklog));
        statement.execute(
                "LOAD DATA LOCAL INFILE 'triples.csv' " +
                        "INTO TABLE triples " +
                        "COLUMNS TERMINATED BY ',' " +
                        "OPTIONALLY ENCLOSED BY '\"' " +
                        "ESCAPED BY '\"' " +
                        "LINES TERMINATED BY '\\r\\n' " +
                        "(id,subject,predicate,object,context,creator,inferred,deleted,createdAt,deletedAt)");

        statement.close();

    } catch (IOException ex) {
        throw new SQLException("error while flushing out data",ex);
    }
}
 
開發者ID:apache,項目名稱:marmotta,代碼行數:38,代碼來源:KiWiMySQLHandler.java

示例9: createTable

import com.mysql.jdbc.Statement; //導入方法依賴的package包/類
private static synchronized void createTable() throws TalesException{

		try {

			
			String sql = "CREATE TABLE `logs` ("
					+ "`id` int(11) NOT NULL AUTO_INCREMENT,"
					+ "`publicDNS` varchar(100) COLLATE utf8_unicode_ci NOT NULL,"
					+ "`pid` int(7) COLLATE utf8_unicode_ci NOT NULL,"
					+ "`logType` varchar(100) COLLATE utf8_unicode_ci NOT NULL,"
					+ "`methodPath` varchar(500) COLLATE utf8_unicode_ci NOT NULL,"
					+ "`lineNumber` int(11) NOT NULL,"
					+ "`data` varchar(5000) COLLATE utf8_unicode_ci NOT NULL,"
					+ "`added` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,"
					+ "PRIMARY KEY (`id`),"
					+ "KEY `publicDNS` (`publicDNS`),"
					+ "KEY `pid` (`pid`),"
					+ "KEY `logType` (`logType`),"
					+ "KEY `methodPath` (`methodPath`(333))"
					+ ") ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=1 ;";

			Statement statement = (Statement) conn.createStatement();
			statement.executeUpdate(sql);
			statement.close();

	
		}catch(Exception e){
			throw new TalesException(new Throwable(), e);
		}

	}
 
開發者ID:matsufan,項目名稱:tales-core,代碼行數:32,代碼來源:LogsDB.java

示例10: showinfo

import com.mysql.jdbc.Statement; //導入方法依賴的package包/類
public void showinfo() throws SQLException{

        String host=SeqBusterView.HosMysText.getText();
        String user=SeqBusterView.UseMysText.getText();
        String pssw=SeqBusterView.PswMysText.getText();
        String namepro=SeqBusterView.loaprotext.getText();
        String port=SeqBusterView.PorMysText.getText();
        if (!port.matches("")){host=host+":"+port;}
        Connection con = (Connection) DriverManager.getConnection ("jdbc:mysql://"+host+"/"+namepro,user,pssw);
        Statement statment = (Statement) con.createStatement();
        String readsamples="select `name` from `experiments` where `description` not like 'noshow'";
        ResultSet rs=statment.executeQuery(readsamples);
        while (rs.next()) {
            ExpList.addItem(rs.getString(1));
            numexp++;

        }

        rs=statment.executeQuery("select `specie` from `seqbuster`.`genome`");

        while (rs.next()) {
            SpeList.addItem(rs.getString(1));

        }

        rs=statment.executeQuery("select count(*) from `seqbuster`.`genome`");
        rs.next();
        NumGenText.setText(rs.getString(1));
        if (rs.getInt(1)==0){
            dobut.setEnabled(false);
        }
        rs=statment.executeQuery("select count(*) from `seqbuster`.`track`");
        rs.next();
        NumTraText.setText(rs.getString(1));
        //int numtrack=Integer.parseInt(rs.getString(1));
        readsamples="select * from `seqbuster`.`track`";
//        Vector listtrack=new Vector();
        rs=statment.executeQuery(readsamples);
        DefaultListModel model = new DefaultListModel();
        //int p=tralist.getModel().getSize();
        int p=0;
        tralist.removeAll();
        while (rs.next()) {

            model.add(p,rs.getString(1));
            p++;

        }

        tralist.setModel(model);
        tralist.repaint();


        rs.close();
        statment.close();
        con.close();
    }
 
開發者ID:lpantano,項目名稱:java_seqbuster,代碼行數:58,代碼來源:CusAnnFrame.java

示例11: createDatabase

import com.mysql.jdbc.Statement; //導入方法依賴的package包/類
private static void createDatabase(String dbName) throws TalesException{


		try {


			final String sql = "CREATE DATABASE " + Globals.DATABASE_NAMESPACE + dbName;
			final Statement statement = (Statement) conn.createStatement();
			statement.executeUpdate(sql);
			statement.close();


		}catch(final Exception e){
			final String[] args = {dbName};
			throw new TalesException(new Throwable(), e, args);
		}

	}
 
開發者ID:matsufan,項目名稱:tales-core,代碼行數:19,代碼來源:DBUtils.java

示例12: createTable

import com.mysql.jdbc.Statement; //導入方法依賴的package包/類
private synchronized void createTable() throws TalesException{

		try {

			Statement statement = (Statement) conn.createStatement();
			statement.executeUpdate("CREATE TABLE " +  taskName + " (id INT NOT NULL, name VARCHAR( 500 ) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL) ENGINE = MYISAM CHARSET=utf8");

			// clone
			statement.close();


		}catch(Exception e){
			String[] args = {taskName};
			throw new TalesException(new Throwable(), e, args);
		}
	}
 
開發者ID:matsufan,項目名稱:tales-core,代碼行數:17,代碼來源:TasksDB.java

示例13: createStringAttributeTable

import com.mysql.jdbc.Statement; //導入方法依賴的package包/類
private synchronized final void createStringAttributeTable(final String attributeName) throws TalesException{


		try {


			String tbName       = Globals.ATTRIBUTE_TABLE_NAMESPACE + attributeName;
			tbName              = tbName.replace(".", "_");

			final Statement statement = (Statement) conn.createStatement();
			statement.executeUpdate("CREATE TABLE " + tbName + " (id INT NOT NULL AUTO_INCREMENT, documentId INT NOT NULL, data VARCHAR(2000) CHARACTER SET utf8 COLLATE utf8_unicode_ci NULL, added TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (id), KEY documentId (documentId)) ENGINE = MYISAM DEFAULT CHARSET=utf8");
			statement.executeUpdate("OPTIMIZE TABLE " + tbName);
			statement.close();


		}catch(final Exception e){
			final String[] args = {attributeName};
			throw new TalesException(new Throwable(), e, args);
		}
	}
 
開發者ID:matsufan,項目名稱:tales-core,代碼行數:21,代碼來源:TalesDB.java

示例14: createIgnoredDocumentsTable

import com.mysql.jdbc.Statement; //導入方法依賴的package包/類
private final synchronized void createIgnoredDocumentsTable() throws TalesException{


		try {


			final String sql = "CREATE TABLE ignoredDocuments ("
					+ "id INT NOT NULL AUTO_INCREMENT, "
					+ "name VARCHAR(1000) NOT NULL, "
					+ "added timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, "
					+ "PRIMARY KEY (id)" 
					+ ") ENGINE = MYISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;";


			final Statement statement = (Statement) conn.createStatement();
			statement.executeUpdate(sql);
			statement.close();


		}catch(final Exception e){
			throw new TalesException(new Throwable(), e);
		}

	}
 
開發者ID:matsufan,項目名稱:tales-core,代碼行數:25,代碼來源:TalesDB.java

示例15: deleteTaskTablesFromDomain

import com.mysql.jdbc.Statement; //導入方法依賴的package包/類
public static void deleteTaskTablesFromDomain(String domain) throws TalesException {

		try {


			// connects
			Class.forName("com.mysql.jdbc.Driver");
			Connection conn = DriverManager.getConnection("jdbc:mysql://"+
					Config.getTasksDBHost(domain)+":"+Config.getDBPort(domain)+"/"+
					"tales_tasks" +
					"?user=" + Config.getDBUsername() +
					"&password=" + Config.getDBPassword() +
					"&useUnicode=true&characterEncoding=UTF-8"
					);


			// gets all the tables that contains the domain name
			Statement statement = (Statement) conn.createStatement();
			ResultSet rs = statement.executeQuery("SHOW TABLES LIKE '%" + domain + "'");

			while(rs.next()){


				Logger.log(new Throwable(), "dropping task table \"" + rs.getString(1) + "\"");
				Statement statement2 = (Statement) conn.createStatement();
				statement2.executeUpdate("DROP TABLE " + rs.getString(1));
				statement2.close();

			}

			rs.close();
			statement.close();
			conn.close();


		}catch(Exception e){
			throw new TalesException(new Throwable(), e);
		}

	}
 
開發者ID:matsufan,項目名稱:tales-core,代碼行數:41,代碼來源:TasksDB.java


注:本文中的com.mysql.jdbc.Statement.close方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。