您好, 欢迎来到 !    登录 | 注册 | | 设为首页 | 收藏本站

hibernate引发NullPointerException

hibernate引发NullPointerException

该消息向我表明它无法连接到数据库。仔细检查您的连接字符串,并确保您的驱动程序在类路径中。我还认为您需要将“ jdbc”作为连接字符串的一部分,除非最近进行了更改。

<property name="hibernate.connection.url" value="jdbc:postgres://****:****@ec2-***-**-***-***.compute-1.amazonaws.com:6232/*****"/>

编辑:我只是盯着这个库的先前版本的来源,如果第214行与这两个版本相同,则您的连接肯定为空(即未发生)。

这是DriverManagerConnectionProviderImpl我方便使用的版本的214行:(4.2.0.CR2)

214     if ( conn.getAutoCommit() != autocommit ) {
215         conn.setAutoCommit(autocommit);
216     }

以下是前几行:

198     Connection conn;
199     if ( driver != null ) {
200         // If a Driver is available, completely circumvent
201         // DriverManager#getConnection.  It attempts to double check
202         // ClassLoaders before using a Driver.  This does not work well in
203         // OSGi environments without wonky workarounds.
204         conn = driver.connect( url, connectionProps );
205     }
206     else {
207         // If no Driver, fall back on the original method.
208         conn = DriverManager.getConnection( url, connectionProps );
209     }
210     
211     if ( isolation != null ) {
212         conn.setTransactionIsolation( isolation.intValue() );
213     }
214     if ( conn.getAutoCommit() != autocommit ) {
215         conn.setAutoCommit(autocommit);
216     }
其他 2022/1/1 18:16:43 有305人围观

撰写回答


你尚未登录,登录后可以

和开发者交流问题的细节

关注并接收问题和回答的更新提醒

参与内容的编辑和改进,让解决方法与时俱进

请先登录

推荐问题


联系我
置顶