Package com.mysql.jdbc

Examples of com.mysql.jdbc.Statement.executeQuery()


    public ResultSet selectQuery( String sqlStatement ) {
        System.out.println( sqlStatement );
        try {
            Statement stmt = ( Statement ) connection.getConnection().createStatement();

            return stmt.executeQuery( sqlStatement );
        } catch( SQLException e ) {
            System.out.println( e.getMessage() );
            throw new RuntimeException();
        }
    }
View Full Code Here


    public static void main(String args[]) {
        DbUtility conn = new DbUtility();
        try {
            String query = "select * from pemilikkos";
            Statement statement = (Statement) conn.getConnection().createStatement();
            ResultSet result = statement.executeQuery(query);

            while (result.next()) {
                System.out.println("userName : " + result.getString("idpemilik"));
                System.out.println("Password  : " + result.getString("password"));
              
View Full Code Here

   
    ResultSet executeQuery(String query){
        ResultSet res = null;
        try {
            Statement statement = (Statement) conn.createStatement();
            res = (ResultSet) statement.executeQuery(query);
            /* we must not close the statement here, otherwise res drops */
        } catch (SQLException ex) {
            Log4k.error(dbConnector.class.getName(),
                    ex.getMessage() + "\n\tquery was " + query);
        }
View Full Code Here

    ArrayList<String> resReturn = new ArrayList<String>();
   
    try {
      ResultSet result;
      Statement state = (Statement) con.createStatement();
      result = state.executeQuery(query);
     
      while(result.next()){
        resReturn.add(result.getString(col));
      }
     
View Full Code Here

      ResultSet rs=null;
      if(con == null)getConnection(); //连接到数据库  
          try
            Statement st = null;   //创建用于执行静态sql语句的Statement对象,st属局部变量  
            st=(Statement) con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_READ_ONLY);
              rs = st.executeQuery(sql);    //执行sql查询语句,返回查询数据的结果集              
              log.info("执行成功:SQL查询语句-->【"+sql+"】");
          }       
            catch (SQLException e) { 
              log.error("执行失败:SQL查询语句-->【"+sql+"】");
              log.error(e.getMessage());
View Full Code Here

    public List getPipeLineListByObjectInspectionId(Integer id, Properties props) throws SQLException {

        Connection dbConn = getConnection(props);
        Statement st = (Statement) dbConn.createStatement();
        ResultSet rs = (ResultSet) st.executeQuery("select * from pipeLineElement where objectId=" + id);
        List plList = setValues(rs);
        rs.close();
        return plList;


View Full Code Here

    public List getPipeLineListByObjectInspectionAndDetailType(Integer typeId, Integer objectId, Properties props) throws SQLException {


        Connection dbConn = getConnection(props);
        Statement st = (Statement) dbConn.createStatement();
        ResultSet rs = (ResultSet) st.executeQuery("select * from pipeLineElement where objectId=" + objectId + " and detailTypeId=" + typeId);
        List plList = setValues(rs);
        rs.close();

        return plList;
    }
View Full Code Here

    try {
      Statement st = null; // 创建用于执行静态sql语句的Statement对象,st属局部变量
      st = (Statement) con
          .createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,
              ResultSet.CONCUR_READ_ONLY);
      rs = st.executeQuery(sql); // 执行sql查询语句,返回查询数据的结果集
      log.info("执行成功:SQL查询语句-->【" + sql + "】");
    } catch (SQLException e) {
      log.error("执行失败:SQL查询语句-->【" + sql + "】");
      log.error(e.getMessage());
      rs = null;
View Full Code Here

    public List getConstructionDefectZonesByConstrType(String typeId,  String buildingObjectId,Properties props) throws SQLException {


        Connection dbConn = getConnection(props);
        Statement st = (Statement) dbConn.createStatement();
        ResultSet rs = (ResultSet) st.executeQuery("select constructionDefectsZone.constructionDefectId from constructionExamples, constructionDefectsZone where constructionExamples.buildObjectId="+buildingObjectId+" and constructionExamples.exampleId=constructionDefectsZone.exampleId and constructionDefectsZone.constructionTypeId="+typeId+" group by uniqueForExamples");
        List plList = setValues(rs);
        rs.close();

        return plList;
    }
View Full Code Here

    }

    public List getExamplesByDefect(String unique,Properties properties) throws SQLException {
        Connection dbConn = getConnection(properties);
        Statement st = (Statement) dbConn.createStatement();
        ResultSet rs = (ResultSet) st.executeQuery("select exampleId from constructionDefectsZone where uniqueForExamples="+unique);
        List list=new ArrayList();
        while (rs.next()) {
              list.add(rs.getString(1));
        }
        rs.close();
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.