postgresql连接尝试失败。

时间:2014-06-09 11:12:17

标签: postgresql openerp-7

好吧,我在ubuntu 12.04lts上使用openerp7 我试图连接到postgresql与非成功,我在网络服务器tomcat7上添加jar,但它不起作用 我收到此错误:org.postgresql.util.PSQLException:连接尝试失败。 这是我的代码:

Connection c = null;
    java.sql.Statement stmt = null;

      try {
        Class.forName("org.postgresql.Driver");
        c = DriverManager.getConnection("jdbc:postgresql://192.168.1.107:5432/test11_05_2014","openerp","admin");
       // System.out.println("Opened database successfully");     
        String sql = "insert into res_groups_users_rel (uid,gid) values (?,?)";
      ///  System.out.println("sql");

       PreparedStatement preparedStatement = c.prepareStatement(sql);
      // preparedStatement.setInt(1,(Integer)(Users_id));
       preparedStatement.setInt(2,1);
       preparedStatement.executeUpdate();  

       preparedStatement.close();
       c.close();

      } catch ( Exception e ) {
     System.err.println( e.getClass().getName()+": "+ e.getMessage() );
      System.exit(0);
      }

我的openerp-server.conf:

[options]
; This is the password that allows database operations:
admin_passwd = admin
db_host = False
db_port = False
db_user = openerp
db_password = False
addons_path = /opt/openerp/v7/addons,/opt/openerp/v7/web/addons,/opt/openerp-custom/addons
;Log settings
logfile = /var/log/openerp/openerp-server.log
log_level = error

谢谢你的帮助。

0 个答案:

没有答案