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


Java Statement.executeQuery方法代碼示例

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


在下文中一共展示了Statement.executeQuery方法的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: GetConsultationStatus

import com.mysql.jdbc.Statement; //導入方法依賴的package包/類
/**
 * Returns the db_status of a consultation from the db.
 *
 * @param curl - The consultation's url
 * @return - The consultation's db status
 * @throws java.sql.SQLException
 */
public static String GetConsultationStatus(String curl) throws SQLException {
    Statement stmt = connection.createStatement();
    ResultSet rs = stmt.executeQuery("SELECT completed FROM consultation WHERE consultation_url  = '" + curl + "';");
    int db_status = 0;
    if (rs.next()) {
        db_status = rs.getInt(1);
    }
    if (db_status == 2) {
        return "blue";
    } else if (db_status == 1) {
        return "red";
    } else {
        return "green";
    }
}
 
開發者ID:scify,項目名稱:DemocracIT-GreekCrawler,代碼行數:23,代碼來源:DB.java

示例6: getUsers

import com.mysql.jdbc.Statement; //導入方法依賴的package包/類
public void getUsers(){
	Connection connessione = null;
	ResultSet rs ;
	String risf;
	try{
		connessione = this.getConnection();
		String query2 = "SELECT DATA,USERNAME FROM users;";
		Statement qry = (Statement) connessione.prepareStatement(query2);	
		rs=qry.executeQuery(query2);
		int numRecord=0;
		while( rs.next() ){
			numRecord++;
			String u=rs.getString("USERNAME");
			java.sql.Date dataCreazione=rs.getDate("DATA");
			System.out.println(u+"\t\tCreato il "+dataCreazione);
		}
		System.out.println("Record letti:"+numRecord);
		rs.close();

	} catch (Exception ex) {
		System.out.println("SQLException: "+ ex.getMessage());
	}
}
 
開發者ID:melnun,項目名稱:NE-Project,代碼行數:24,代碼來源:UserDAO.java

示例7: getResultSet

import com.mysql.jdbc.Statement; //導入方法依賴的package包/類
public static ResultSet getResultSet(String sqlString) throws SQLException, ClassNotFoundException
{
	Connection conn = getConnection();
	Statement stm = (Statement) conn.createStatement();		
	ResultSet rs = stm.executeQuery(sqlString);
	return rs;
}
 
開發者ID:shuqin,項目名稱:ALLIN,代碼行數:8,代碼來源:JDBCUtil.java

示例8: GetConsultationId

import com.mysql.jdbc.Statement; //導入方法依賴的package包/類
/**
 * Returns the ID of a given consultation if already on the DB else returns
 * -1.
 *
 * @param curl - The consultation's url
 * @return - The consultation's db id
 * @throws java.sql.SQLException
 */
public static int GetConsultationId(String curl) throws SQLException {
    Statement stmt = connection.createStatement();
    ResultSet rs = stmt.executeQuery("SELECT ID FROM Consultation WHERE consultation_url = '" + curl + "';");
    int id = -1;
    if (rs.next()) {
        id = rs.getInt(1);
    }
    return id;
}
 
開發者ID:scify,項目名稱:DemocracIT-GreekCrawler,代碼行數:18,代碼來源:DB.java

示例9: InsertOrganization

import com.mysql.jdbc.Statement; //導入方法依賴的package包/類
/**
 * Inserts organizations into DB.
 *
 * @param ministry - The ministry object
 * @param url - The url of the ministry
 * @throws java.sql.SQLException
 */
public static void InsertOrganization(Object ministry, String url, String minGroup) throws SQLException {
    Statement stmt = connection.createStatement();
    ResultSet rs = stmt.executeQuery("SELECT ID, GROUP_TITLE FROM ORGANIZATION_LKP WHERE title = '" + ministry + "';");
    int id = -1;
    if (rs.next()) {
        id = rs.getInt(1);
        String group_title = rs.getString(2);
        if (group_title == null || !group_title.equals(minGroup)) {
            stmt.executeUpdate("UPDATE ORGANIZATION_LKP SET group_title = '" + minGroup + "' WHERE id = " + id + ";");
        }
    } else {
        stmt.execute("INSERT INTO ORGANIZATION_LKP (title, url_initial) VALUES ('" + ministry + "','" + url + "');");
    }
}
 
開發者ID:scify,項目名稱:DemocracIT-GreekCrawler,代碼行數:22,代碼來源:DB.java

示例10: GetOrganizationId

import com.mysql.jdbc.Statement; //導入方法依賴的package包/類
/**
 * Returns the ID of a given Organization if already on the DB else Inserts
 * the new Organization into DB.
 *
 * @param ministry - The name of the ministry
 * @return - The DB id of any given ministry
 * @throws java.sql.SQLException
 */
public static int GetOrganizationId(Object ministry) throws SQLException {
    Statement stmt = connection.createStatement();
    ResultSet rs = stmt.executeQuery("SELECT ID FROM ORGANIZATION_LKP WHERE TITLE = '" + ministry + "';");
    int id = -1;
    if (rs.next()) {
        id = rs.getInt(1);
    }
    return id;
}
 
開發者ID:scify,項目名稱:DemocracIT-GreekCrawler,代碼行數:18,代碼來源:DB.java

示例11: CheckSkipList

import com.mysql.jdbc.Statement; //導入方法依賴的package包/類
/**
 * Checks if a consultation is into a skip list, in order to skip crawling
 *
 * @param consultationPage - The consultation's page url
 * @return - True if consultation exists in skip list
 * @throws java.sql.SQLException
 */
static boolean CheckSkipList(String consultationPage) throws SQLException {
    boolean exists = false;
    Statement stmt = connection.createStatement();
    ResultSet rs = stmt.executeQuery("SELECT id FROM log.consultation_skip_list WHERE url = '" + consultationPage + "';");
    int id = -1;
    if (rs.next()) {
        id = rs.getInt(1);
        exists = true;
    }
    return exists;
}
 
開發者ID:scify,項目名稱:DemocracIT-GreekCrawler,代碼行數:19,代碼來源:DB.java

示例12: UpdateGroupOfRemovedMinitries

import com.mysql.jdbc.Statement; //導入方法依賴的package包/類
static boolean UpdateGroupOfRemovedMinitries(HashSet ogReadMins) throws SQLException {
        Statement stmt = connection.createStatement();
        ResultSet rs = stmt.executeQuery("SELECT title FROM ORGANIZATION_LKP;");
        HashSet dbMinTitles = new HashSet();
//        int id = -1;
        while (rs.next()) {
            dbMinTitles.add(rs.getString(1));
//            String group_title = rs.getString(2);
//            if (group_title== null || !group_title.equals(minGroup)){
//                stmt.executeUpdate("UPDATE ORGANIZATION_LKP SET group_title = '" + minGroup + "' WHERE id = " + id + ";");
//            }
        }
        if (dbMinTitles.size() != ogReadMins.size()) {
            ArrayList<String> deprecatedMins = new ArrayList<String>(CollectionUtils.subtract(dbMinTitles, ogReadMins));
            String updMinGroup = "UPDATE ORGANIZATION_LKP SET "
                    + "group_title = ?"
                    + "WHERE title = ?";
            PreparedStatement prepUpdUrlsSt = connection.prepareStatement(updMinGroup);
            for (String minName : deprecatedMins) {
                prepUpdUrlsSt.setString(1, "Deprecated");
                prepUpdUrlsSt.setString(2, minName);
                prepUpdUrlsSt.executeUpdate();
            }
            prepUpdUrlsSt.close();
        }
        return false;
    }
 
開發者ID:scify,項目名稱:DemocracIT-GreekCrawler,代碼行數:28,代碼來源:DB.java

示例13: main

import com.mysql.jdbc.Statement; //導入方法依賴的package包/類
public void main (String[] args)
{
	Connection connessione = null;
	ResultSet rs ;
	String risf;
	try{
		connessione = DriverManager.getConnection("jdbc:mysql://localhost/ne?user=root");
		System.out.println("Connessione:"+connessione);
		String query2 = "SELECT DATA,USERNAME FROM users;";
		Statement qry = (Statement) connessione.prepareStatement(query2);
		String query = "INSERT INTO 'users' ('Username, 'Pass', 'Flag', 'Data') VALUES ('gandalf','frodo', 0, '2014-09-22')";			
		rs=qry.executeQuery(query2);
		int numRecord=0;
		while( rs.next() ){
			numRecord++;
			String u=rs.getString("USERNAME");
			java.sql.Date dataCreazione=rs.getDate("DATA");
			System.out.println(u+"\t\tCreato il "+dataCreazione);
		}
		System.out.println("Record letti:"+numRecord);
		rs.close();
		
		//risf = ris.toString();
		//System.out.println(risf);
	} catch (Exception ex) {
		System.out.println("SQLException: "+ ex.getMessage());
		//			System.out.println("SQLState: "+ ex.getSQLState());
		//			System.out.println("VendorError: "+ ex.getErrorCode());
	}
}
 
開發者ID:melnun,項目名稱:NE-Project,代碼行數:31,代碼來源:TestConnection.java

示例14: 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

示例15: SpeListItemStateChanged

import com.mysql.jdbc.Statement; //導入方法依賴的package包/類
private void SpeListItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_SpeListItemStateChanged
    // TODO add your handling code here:
    
    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;}
    
    String spe = (String)SpeList.getSelectedItem();
    Connection con = null;
    try {
        con = (Connection) DriverManager.getConnection("jdbc:mysql://"+host+"/"+namepro,user,pssw);
        Statement statment = (Statement) con.createStatement();
        //statment.executeUpdate("drop table if exists `"+expname+"clusraw` ");
        String readsamples="select `name` from `seqbuster`.`genome` where `specie` like '"+spe+"' ";
        ResultSet rs=statment.executeQuery(readsamples);


        while (rs.next()) {

            GenList.addItem(rs.getString(1));

        }
    } catch (SQLException ex) {
        Logger.getLogger(NonMiRNAFrame.class.getName()).log(Level.SEVERE, null, ex);
    }

}
 
開發者ID:lpantano,項目名稱:java_seqbuster,代碼行數:31,代碼來源:CusAnnFrame.java


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