是javax.sql.DataSource线程安全吗? [英] is javax.sql.DataSource thread safe?

查看:564
本文介绍了是javax.sql.DataSource线程安全吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在JBoss 7中部署的Java EE应用程序中使用PostgreSQL 9.1 JDBC4驱动程序(postgresql-9.1-902.jdbc4.jar)。

I am using the PostgreSQL 9.1 JDBC4 driver (postgresql-9.1-902.jdbc4.jar) in a Java EE application deployed in JBoss 7.

我可以假设 javax.sql.DataSource 是线程安全的,这样多个线程可以同时调用它上面的getConnection()方法吗?

Can I assume that javax.sql.DataSource is thread-safe so that multiple threads can concurrently call the getConnection() method on it?

推荐答案

javax.sql.DataSource 本身是一个接口,所以它是一个特定的实现,如果它是线程安全的。

javax.sql.DataSource itself is an interface, so it is a specific to the implentation if it is thread-safe or not.

对于postgres sql驱动程序,我建议你阅读官方的第10章在多线程或Servlet环境中使用驱动程序文档:

For the postgres sql driver, I recommend that you read Chapter 10. Using the Driver in a Multithreaded or a Servlet Environment from the official documentation:


PostgreSQL JDBC驱动程序是线程安全的。 [...]

The PostgreSQL JDBC driver is thread safe. [...]

这篇关于是javax.sql.DataSource线程安全吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆