TransPort_Tracking
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
|
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package com.bestray.transporttracking;
import com.bestray.transtracking.exceptions.TransTrackException;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.Properties;
import javax.sql.DataSource;
import org.springframework.jdbc.datasource.DriverManagerDataSource;
/**
*
* @author Girija Sahu
*/
public class DataSourceObject {
private static DriverManagerDataSource ds;
private static Properties properties;
public static DataSource getDataSourceObject()throws TransTrackException{
try{
properties=new Properties();
FileInputStream fis=new FileInputStream(System.getProperty("user.home")+File.separator+"transtrack"+"/transtrack.properties");
properties.load(fis);
fis.close();
File file =new File(System.getProperty("user.home")+File.separator+"transtrack"+"/transtrack.properties");
if (ds == null || isFileUpdated(file)) {
ds = new org.springframework.jdbc.datasource.DriverManagerDataSource();
ds.setDriverClassName(properties.getProperty("driverClassName"));
ds.setUrl(properties.getProperty("url"));
ds.setUsername(properties.getProperty("user"));
ds.setPassword(properties.getProperty("password"));
}
}catch(IOException ie){
throw new TransTrackException(" Failed to load the Driver");
}
return ds;
}
private static long timeStamp;
private static File file;
private static boolean isFileUpdated( File file1 ) {
file=file1;
long timeStamp1 = file.lastModified();
if( timeStamp != timeStamp1 ) {
timeStamp = timeStamp1;
return true;
}
return false;
}
}
|
Revision |
Author |
Commited |
Message |
1
|
girijabapi
|
Sat 28 Jul, 2018 05:29:14 +0000 |
|