Satyam
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package com.bestray.labinformationsystem.util;
import java.sql.Connection;
import javax.sql.DataSource;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.jdbc.datasource.DataSourceUtils;
// TODO: Auto-generated Javadoc
/**
* A factory for creating Connection objects.
*/
public class ConnectionFactory{
/** The con. */
private static Connection con;
/** The ds. */
private static DataSource ds;
public static ApplicationContext context ;
static{
context = new ClassPathXmlApplicationContext("labInformationDataAccessContext.xml");
ds=(DataSource)context.getBean("dataSource");
}
/**
* Gets the con.
*
* @return the con
*/
public static Connection getCon(){
try{
con=DataSourceUtils.getConnection(ds);
}catch(Exception e){
e.printStackTrace();
}
return con;
}
}
|
Revision |
Author |
Commited |
Message |
1
|
girijabapi
|
Fri 20 Jul, 2018 05:59:17 +0000 |
|