- 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