Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- 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
- D:\Asterisk-Java\test\ivr>javac -cp .\ivrlib\lib\postgresql-8.3-603.jdbc4.jar DBtest2.java
- And run like this
- >java DBtest2
- No driver
- */
- import java.sql.*;
- class DBtest2{
- public static void main(String[] args)
- {
- String driver ="org.postgresql.Driver";
- String connectString = "jdbc:postgresql://10.10.10.10:5432/db";
- String user = "xxxx";
- String password = "qqqqq";
- try{
- Class.forName(driver);
- Connection con = DriverManager.getConnection(connectString, user , password);
- Statement stmt = con.createStatement();
- ResultSet rs = stmt.executeQuery("select f_xx from t_xxxx");
- while (rs.next()){
- System.out.println("celular::" + rs.getString("f_xx"));
- }
- stmt.close();
- con.close();
- }
- catch ( Exception e ){
- System.out.println("No driver");
- System.out.println(e.getMessage());
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement