- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
当使用 Firebird 的 jaybird JDBC 驱动程序将 null
绑定(bind)到 PreparedStatement
时,我遇到了一些特殊情况。这是一个示例语句:
Class.forName("org.firebirdsql.jdbc.FBDriver");
// Observe the "local" in the connection string!
Connection con = DriverManager.getConnection(
"jdbc:firebirdsql:local:C:/data/firebird/test.db", "TEST", "TEST");
// With this connection, I'm not able to reproduce the issue:
Connection con1 = DriverManager.getConnection(
"jdbc:firebirdsql:localhost:C:/data/firebird/test.db", "TEST", "TEST");
PreparedStatement stmt = con.prepareStatement(
"SELECT cast(? as varchar(1)) FROM rdb$database");
stmt.setObject(1, null);
ResultSet rs = stmt.executeQuery();
rs.next();
System.out.println(rs.getString(1));
System.out.println(rs.wasNull());
上面程序的输出是
>
> false
第一行是一个空字符串。确实应该是
> null
> true
改变这一行...
stmt.setObject(1, null);
...进入任何这些行...
stmt.setString(1, null);
stmt.setNull(1, Types.VARCHAR);
...也无济于事。解决方法是在 SQL 语句中内联 null
文字,而不是将它们绑定(bind)到准备好的语句。我错过了什么?
详细信息:
最佳答案
我无法在 Windows 7 x64 上的 Jaybird 2.2.0 和 Firebird 2.1.3(32 位) 上重现该问题.复制粘贴源代码并运行它会产生预期的输出。
附上截图以防万一:
更新
在 Windows XP 上的 Jaybird 2.2.0 和 Firebird 2.5.1(32 位) 上测试,仍然无法重现问题 -> 完全正确与预期相同的输出。
关于java - 如何使用 Firebird 的 jaybird JDBC 驱动程序将绑定(bind)值设置为 NULL?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12106422/
我是 Firebird 的新手,使用其 Java 版本 Jaybird,但无法从数据库(.fdb 文件)连接。问题是这样的: org.firebirdsql.jdbc.FBSQLException:
您知道是否有一种方法可以在 jaybird 的选择查询上使用数据监听器。 例如,我有一个类似的查询 select count (*) from my_table where my_statut='x'
我正在使用 Java 中的 Firebird 数据库。一切正常,但如果数据库文件路径包含国家字符,例如,我在连接到数据库时遇到问题。 “á”或“č”。 异常示例: org.firebirdsql.jd
我有这个 Java 代码: Connection conn = connectionProvider.getConnection(); statement = conn.prepareCall("ex
我需要使用数据库 Firebird,为此我使用 Jaybird 2.2.9。 当我使用 MySQL 驱动程序时,将 ResultSet 转换为 Object 如下: empresa.setBairro
可能我问的是一个常见问题,但我真的不明白我做错了什么,以及当我尝试通过 Jaybird 连接我的 Firebird DB 时我可能会忘记什么。我已将 Jaybird.jar 添加到我的 Java 构建
我正在使用 JDBC 连接到 firebird。 org.firebirdsql.jdbc jaybird-jdk18 3.0.5 当我读取数据时: resultSet.next(); //resul
我是 Linux/Java/Scriptella 的新手,我正在尝试在 Firebird 本地数据库上使用 scriptella 进行 jdbc 连接,但我收到以下错误: 2-dic-2013 1.0
我正在使用 jaybird 2.2.3 和 hibernate 3.5,当我使用向导 hibernate 映射文件和 pojos 数据库时出现以下错误“java.lang.NullPointerExc
我很想看看 Firebird 与 Hibernate 的性能,但我无法让它正确运行。我添加到我的 pom.xml: net.sf.squirrel-sql.thirdparty-non-ma
在以前版本的 jaybird (2.2) 中,我能够对 Firebird 服务器执行服务 API 以获取 Activity 事务标记:OIT、OAT、Next 等。 在 3.0 版中,我找不到正确的方
我正在创建一个连接到 Firebird 数据库并检索一些数据的 Java 应用程序。程序完成,在我的电脑上运行良好。问题是,在我需要运行应用程序的计算机上,数据库位于本地网络中的另一台计算机上,我不知
我确实通过 FBUserManager.add(user) 在 Firebird 中成功创建了一个新用户。我也成功连接到了我已经创建的数据库。我无法知道如何运行查询,我收到消息: “org.fireb
我在 Android 上使用 Firebird 直接 wifi 连接创建了一个应用程序。有时我会收到此错误: FATAL EXCEPTION: AsyncTask #4 java.lang.Runti
我正在 eclipse 中开发一个小程序,当从 eclipse 的 AppletViewer 执行时,它可以正常工作,但是当从 .html 文件执行时,它不会执行 class.forName() 方法
我对使用联合的新 SQL 查询有点困惑。 我使用 jaybird 2.2.8 在 java 应用程序中请求我的 firebird 数据库。通常我使用 MetaData 解析我的结果集 ResultSe
当使用嵌入式 firebird 导出我的 java 项目时,我在控制台中收到以下消息: “在 java.library.path 中没有 jaybird[22[任何版本,我猜]]”。 但它实际上是在我
我一直在开发一个连接到 Firebird 数据库并监听事件的程序。我试图让它与嵌入式数据库一起工作。 EventManager em = new FBEventManager(GDSType.getT
我正在尝试使用 lib jaybird 2.1.6 在 Firebird 数据库的 blob 字段中插入文件。 首先,我在数据库中创建一条记录,然后,使用记录 ID,尝试将文件插入到 blob(子类型
我已将 Wildfly 10 中的 Jaybird 依赖项从 Jaybird 2.2.11 升级到 Jaybird 3.0.0-alpha-1。当我尝试创建连接时,我现在遇到以下异常。 启动后的第一个
我是一名优秀的程序员,十分优秀!