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