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
|
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package com.bestray.transtracking.dao.impl;
import com.bestray.transtracking.dao.CodeDao;
import com.bestray.transtracking.dao.mapper.CodeMapper;
import com.bestray.transtracking.dao.mapper.CodeResultSetExtractor;
import com.bestray.trastrack.domain.Code;
import java.util.List;
import javax.sql.DataSource;
import org.springframework.jdbc.core.JdbcTemplate;
/**
*
* @author Girija Sahu
*/
public class CodeDaoImpl implements CodeDao {
private DataSource ds;
public CodeDaoImpl(DataSource ds) {
this.ds = ds;
}
public List<Code> getCodesByCodeTypeName(String codeTypeName) throws Exception{
JdbcTemplate template = new JdbcTemplate(ds);
String query = "Select cd.id,cd.name from code cd,codetype ct where cd.code_type_id = ct.id and ct.name =?";
List<Code> codeList = (List<Code>) template.query(query, new Object[]{codeTypeName}, new CodeResultSetExtractor());
return codeList;
}
public Code getCodeById(Long codeId) throws Exception{
JdbcTemplate template = new JdbcTemplate(ds);
String query = "Select cd.id,cd.name from code cd where cd.id =?";
List<Code> codeList = (List<Code>) template.query(query, new Object[]{codeId}, new CodeResultSetExtractor());
return codeList.size()>0?codeList.get(0):null;
}
public List<Code> searchByCodeValue(String codeType, String searchCdeVal)throws Exception {
JdbcTemplate template = new JdbcTemplate(ds);
String query = "Select cd.id,cd.name from code cd,codetype ct where cd.code_type_id = ct.id and ct.name =? and cd.code_value=?";
// System.out.println(query);
List<Code> codeList = (List<Code>) template.query(query, new Object[]{codeType, searchCdeVal}, new CodeResultSetExtractor());
return codeList;
}
public List<Code> getAllCodes() throws Exception{
JdbcTemplate template = new JdbcTemplate(ds);
String query = "Select *from code";
List<Code> codeList = (List<Code>) template.query(query, new Object[]{}, new CodeResultSetExtractor());
return codeList;
}
}
|
Revision |
Author |
Commited |
Message |
1
|
girijabapi
|
Sat 28 Jul, 2018 05:29:14 +0000 |
|