Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- String query = "SELECT * FROM table WHERE UNIQUEID=? AND DIR IS NOT NULL AND NAME IS NOT NULL AND PAGETYPE IS NOT NULL";
- DBConnect Database = new DBConnect();
- Connection con = null;
- PreparedStatement ps = null;
- ResultSet rs=null;
- try {
- con = Database.getcon();
- ps = con.prepareStatement(query);
- ps.setString(1, URI);
- rs=ps.executeQuery();
- if(rs.next()){
- }
- } finally {
- if(ps != null)
- ps.close();
- if(rs != null)
- rs.close();
- if(con != null)
- con.close();
- }
- query = "SELECT COUNTCOMMENTS FROM videosinfos WHERE UNIQUEID=?";
- try {
- con = Database.getcon();
- ps = con.prepareStatement(query); // Getting error here
- rs=ps.executeQuery();
- ps.setString(1, URI);
- rs=ps.executeQuery();
- if(rs.next()){
- comments = rs.getInt(1);
- }
- ps.close();
- rs.close();
- con.close();
- } finally {
- if(ps != null)
- ps.close();
- if(rs != null)
- rs.close();
- if(con != null)
- con.close();
- }
- public DBConnect(){
- try{
- Class.forName("com.mysql.jdbc.Driver");
- String unicode="useSSL=false&autoReconnect=true&useUnicode=yes&characterEncoding=UTF-8";
- con = DriverManager.getConnection("jdbc:mysql://localhost:15501/duckdb?"+unicode, "root", "_PWD");
- st = con.createStatement();
- }catch(Exception ex){
- System.out.println(ex.getMessage());
- System.out.println("couldn't connect!");
- }
- }
- public Connection getcon(){
- DBConnect condb = new DBConnect();
- Connection connect = con;
- return con;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement