- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
package parseit;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
public class MysqlConn {
private volatile static Connection instance;
private MysqlConn() {
}
public static Connection getInstance() {
try {
if (instance == null) {
synchronized (MysqlConn.class) {
if (instance == null) {
instance = DriverManager.getConnection("jdbc:mysql://***:3306/******?user=******&password=*******");
}
}
}
} catch (SQLException ex) {
}
return instance;
}
}
Объясните почему System.out.println(MysqlConn.getInstance ()); выводит null
guest 30.09.2009 09:08 # +1
guest 30.09.2009 10:16 # +3
guest 30.09.2009 19:33 # 0
guest 30.09.2009 20:46 # −1
striker 01.10.2009 14:46 # 0
5838151 01.10.2009 00:57 # 0
kingoleg 09.06.2010 17:28 # 0