Last active
December 14, 2015 00:19
-
-
Save anupsavvy/4998535 to your computer and use it in GitHub Desktop.
Singleton Class
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class DataSource { | |
private Connection connection = null; | |
private static DataSource datasource = null; | |
// private constructor | |
private DataSource(){ | |
connection = getConnection(); | |
} | |
// method to get an instance. | |
public static DataSource getInstance(){ | |
if(datasource == null){ | |
datasource = new DataSource(); | |
} | |
return datasource; | |
} | |
private Connection getConnection(){ | |
// code to get database connection. | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment