daily pastebin goal
45%
SHARE
TWEET

Untitled

a guest Jun 4th, 2017 63 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*
  2. I have problem trying to run this. Always I get No driver, I dont know anything else, I am using windows and for compiling I get this
  3.  
  4. D:\as\ivr>javac -cp .\ivrlib\lib\postgresql-8.3-603.jdbc4.jar DBtest2.java
  5. And run like this
  6.  
  7. >java DBtest2
  8. No driver
  9. */
  10. import java.sql.*;
  11.  
  12.     class DBtest2{
  13.     public static void main(String[] args)
  14.     {
  15.     String driver ="org.postgresql.Driver";
  16.     String connectString = "jdbc:postgresql://10.10.10.10:5432/db";
  17.     String user = "xxxx";
  18.     String password = "qqqqq";
  19.  
  20.     try{
  21.     Class.forName(driver);
  22.     Connection con = DriverManager.getConnection(connectString, user , password);
  23.     Statement stmt = con.createStatement();
  24.  
  25.     ResultSet rs = stmt.executeQuery("select f_xx from t_xxxx");
  26.  
  27.     while (rs.next()){
  28.     System.out.println("celular::" + rs.getString("f_xx"));
  29.     }
  30.  
  31.     stmt.close();
  32.     con.close();
  33.  
  34.     }
  35.  
  36.     catch ( Exception e ){
  37.     System.out.println("No driver");
  38.     System.out.println(e.getMessage());
  39.     }
  40.     }
  41.     }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top