本文整理汇总了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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
示例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;
}
示例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);
}
}
示例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);
}
}
示例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();
}
示例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);
}
}
示例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);
}
}
示例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);
}
}
示例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);
}
}
示例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);
}
}