Home  >  Article  >  Database  >  java-mysql中getConnection();得到的Connection 怪怪的。

java-mysql中getConnection();得到的Connection 怪怪的。

WBOY
WBOYOriginal
2016-06-06 09:39:361082browse

mysqljava

图片说明
这个是返回我的Connection连接对象。
图片说明
我若直接在public static Connection getConnection() 所在类。main方法,以及
在public void add(User user) {所在类 main方法直接调用test(),,每次运行老是给我返回com.mysql.jdbc.JDBC4Connection@446cdf90同一个对象。。
而若间接着好多个类调用先调用new LoginFrame();——》new UserDAOJDBCImpl().test();则给我随机的些Connection对象。。好难理解哦哦。。

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn