NutzCN Logo
问答 springboot postgresql 数据库启动检测报错checkDataSource
发布于 1277天前 作者 sunhai1988 1765 次浏览 复制 上一个帖子 下一个帖子
标签:

springboot postgresql 数据库启动检测报错checkDataSource 这个表pg中不存在吗

 @Override
    public void checkDataSource(Connection conn) throws SQLException {
        if (log.isDebugEnabled()) {
            String sql = "SELECT * FROM information_schema.character_sets";
            Statement stmt = conn.createStatement();
            ResultSet rs = stmt.executeQuery(sql);
            if (rs.next()) {
                for (String name : Arrays.asList("character_set_catalog",
                                                 "character_set_schema",
                                                 "character_set_name",
                                                 "character_repertoire",
                                                 "form_of_use",
                                                 "default_collate_catalog",
                                                 "default_collate_schema",
                                                 "default_collate_name")) {
                    log.debugf("Postgresql : %s=%s", name, rs.getString(name));
                }
            }
            rs.close();
            // 打印当前数据库名称
            rs = stmt.executeQuery("SELECT CURRENT_DATABASE()");
            if (rs.next()) {
                log.debug("Postgresql : database=" + rs.getString(1));
            }
            rs.close();
            // 打印当前连接用户名
            rs = stmt.executeQuery("SELECT CURRENT_USER");
            if (rs.next()) {
                log.debug("Postgresql : user=" + rs.getString(1));
            }
            rs.close();
            stmt.close();
        }
    }
2021-06-24 16:26:03.927 DEBUG [           main] [] org.nutz.dao.jdbc.Jdbcs                  [90] : Jdbcs init complete
2021-06-24 16:26:04.019  INFO [           main] [] org.nutz.dao.jdbc.Jdbcs                  [103] : Get Connection from DataSource for JdbcExpert, if you lock at here, check your database server and configure
2021-06-24 16:26:04.050  INFO [           main] [] com.zaxxer.hikari.HikariDataSource       [110] : HikariPool-1 - Starting...
2021-06-24 16:26:05.168  INFO [           main] [] com.zaxxer.hikari.HikariDataSource       [123] : HikariPool-1 - Start completed.
2021-06-24 16:26:09.143 DEBUG [           main] [] org.nutz.dao.impl.DaoSupport             [190] : select expert : org.nutz.dao.impl.jdbc.psql.PsqlJdbcExpert
2021-06-24 16:26:30.914 DEBUG [           main] [] org.nutz.dao.impl.DaoSupport             [201] : JDBC Driver --> 42.2.8
2021-06-24 16:26:30.917 DEBUG [           main] [] org.nutz.dao.impl.DaoSupport             [202] : JDBC Name   --> PostgreSQL JDBC Driver
2021-06-24 16:26:30.920 DEBUG [           main] [] org.nutz.dao.impl.DaoSupport             [204] : JDBC URL    --> jdbc:postgresql://36.110.98.226:45432/ttsec2_0?useUnicode=true&characterEncoding=UTF-8
2021-06-24 16:27:26.773  INFO [           main] [] org.nutz.dao.impl.DaoSupport             [218] : something wrong when checking DataSource

org.postgresql.util.PSQLException: ERROR: relation "information_schema.character_sets" does not exist
  位置:15
	at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2497)
	at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:2233)
	at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:310)
	at org.postgresql.jdbc.PgStatement.executeInternal(PgStatement.java:446)
	at org.postgresql.jdbc.PgStatement.execute(PgStatement.java:370)
	at org.postgresql.jdbc.PgStatement.executeWithFlags(PgStatement.java:311)
	at org.postgresql.jdbc.PgStatement.executeCachedSql(PgStatement.java:297)
	at org.postgresql.jdbc.PgStatement.executeWithFlags(PgStatement.java:274)
	at org.postgresql.jdbc.PgStatement.executeQuery(PgStatement.java:225)
	at com.zaxxer.hikari.pool.ProxyStatement.executeQuery(ProxyStatement.java:111)
	at com.zaxxer.hikari.pool.HikariProxyStatement.executeQuery(HikariProxyStatement.java)
	at org.nutz.dao.impl.jdbc.psql.PsqlJdbcExpert.checkDataSource(PsqlJdbcExpert.java:191)
	at org.nutz.dao.impl.DaoSupport$1.invoke(DaoSupport.java:215)
	at org.nutz.dao.impl.sql.run.NutDaoRunner.runCallback(NutDaoRunner.java:163)
	at org.nutz.dao.impl.sql.run.NutDaoRunner._runWithoutTransaction(NutDaoRunner.java:130)
	at org.nutz.dao.impl.sql.run.NutDaoRunner._run(NutDaoRunner.java:97)
	at org.nutz.dao.impl.sql.run.NutDaoRunner.run(NutDaoRunner.java:86)
	at org.nutz.dao.impl.DaoSupport.run(DaoSupport.java:242)
	at org.nutz.dao.impl.DaoSupport.setDataSource(DaoSupport.java:195)
	at org.nutz.dao.impl.DaoSupport.setDataSource(DaoSupport.java:180)
	at org.nutz.dao.impl.NutDao.<init>(NutDao.java:108)
6 回复

云服务的?

版本:PostgreSQL 8.2.15 (Greenplum Database 4.3.7.3 build 2) on x86_64-unknown-linux-gnu, compiled by GCC gcc (GCC) 4.4.2 compiled on Feb 25 2016 06:38:30
nutz:1.r.68.v20201205

@wendal 这个报错是 怎么回事呢?

连本地的pgsql正常吗?

主要提示的是表不存在 数据库确实没有这些表

拷贝一下这个类的源码, 把语句注释掉吧

用户类会优先于jar里面的类

添加回复
请先登陆
回到顶部