KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > lucane > server > database > SQLServerLayer


1 /**
2  * @author Xiaozheng Ma
3  * database layer for Miscrosoft SQL2000
4  */

5 package org.lucane.server.database;
6
7 import java.sql.Connection JavaDoc;
8 import java.sql.SQLException JavaDoc;
9
10 import javax.sql.DataSource JavaDoc;
11
12 class SQLServerLayer extends DatabaseAbstractionLayer
13 {
14     private DataSource JavaDoc dataSource;
15     
16     public SQLServerLayer(DataSource JavaDoc dataSource)
17     {
18         this.dataSource = dataSource;
19     }
20     
21     public Connection JavaDoc getConnection()
22     throws SQLException JavaDoc
23     {
24         return dataSource.getConnection();
25     }
26     
27     public String JavaDoc resolveType(String JavaDoc type)
28     {
29         if(type.equalsIgnoreCase("SMALLTEXT"))
30             return "VARCHAR(250)";
31         else if(type.equalsIgnoreCase("TEXT"))
32             return "TEXT";
33         else if(type.equalsIgnoreCase("SMALLINT"))
34             return "SMALLINT";
35         else if(type.equalsIgnoreCase("INT"))
36             return "INT";
37         else if(type.equalsIgnoreCase("BIGINT"))
38             return "BIGINT";
39         else if(type.equalsIgnoreCase("REAL"))
40             return "REAL";
41         else
42             return type;
43     }
44 }
Popular Tags