KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > xquark > mapper > dbms > sybase > ASE119Connection


1 /*
2  * This file belongs to the XQuark distribution.
3  * Copyright (C) 2003 Universite de Versailles Saint-Quentin.
4  *
5  * This program is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2.1 of the License, or (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  * Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public
16  * License along with this program; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307.
18  * You can also get it at http://www.gnu.org/licenses/lgpl.html
19  *
20  * For more information on this software, see http://www.xquark.org.
21  */

22
23 package org.xquark.mapper.dbms.sybase;
24
25 import java.sql.*;
26
27 import org.xquark.jdbc.typing.DBMSInfo;
28 import org.xquark.jdbc.typing.DbType;
29 import org.xquark.jdbc.typing.JavaTypeInfo;
30 import org.xquark.mapper.RepositoryException;
31 import org.xquark.mapper.dbms.JDBC2Connection;
32
33 /**
34  * Implementation of AbstractConnection for Sybase Adaptive Server 11.9.x.
35  *
36  */

37 public class ASE119Connection extends JDBC2Connection
38 {
39     private static final String JavaDoc RCSRevision = "$Revision: 1.2 $";
40     private static final String JavaDoc RCSName = "$Name: $";
41
42     
43     /** Creates new ASE119Connection */
44     public ASE119Connection(Connection connection, short dbms, DBMSInfo dbmsInfo)
45     throws SQLException
46     {
47         super(connection, dbms, dbmsInfo);
48    }
49
50     protected void setSchemaName() throws SQLException
51     {
52         Statement stmt = null;
53         try {
54             stmt = connection.createStatement();
55             ResultSet rs = stmt.executeQuery("select USER_NAME()");
56             if (rs.next())
57                 schemaName = rs.getString(1);
58             rs.close();
59         }
60         finally {
61             stmt.close();
62         }
63     }
64     ///////////////////////////////////////////////////////////////
65
// Sybase ASE 11.x specific methods
66
///////////////////////////////////////////////////////////////
67
public void setObject(PreparedStatement pStmt, int index, Object JavaDoc o, int javaType, DbType sqlType) throws SQLException
68     {
69         if ((javaType == JavaTypeInfo.JAVA_BIG_DECIMAL)
70             && (sqlType.getJDBCType() == Types.DECIMAL)
71             && (sqlType.getScale() <= 2))
72             pStmt.setFloat(index, ((Number JavaDoc)o).floatValue());
73         else
74             pStmt.setObject(index, o);
75     }
76
77     ///////////////////////////////////////////////////////////////
78
// Table methods
79
///////////////////////////////////////////////////////////////
80
public void dropTemporaryTable(String JavaDoc tableName) throws SQLException
81     {
82         super.dropTemporaryTable("#" + tableName);
83     }
84     
85     public String JavaDoc getDeleteUserTableRowsStatement(String JavaDoc tableName, String JavaDoc documentRowsSelectionClause)
86     throws SQLException, RepositoryException
87     {
88         StringBuffer JavaDoc deletionStmt = new StringBuffer JavaDoc();
89         deletionStmt.append("DELETE ");
90         deletionStmt.append(tableName);
91         deletionStmt.append(' ');
92         deletionStmt.append(documentRowsSelectionClause);
93         
94         return deletionStmt.toString();
95     }
96     
97     // TO IMPLEMENT ? public String getPathIndexStatement()
98

99     public boolean useStringDelimitor()
100     {
101         return true;
102     }
103     
104     ///////////////////////////////////////////////////////////////
105
// Private utilities
106
///////////////////////////////////////////////////////////////
107
// TO IMPLEMENT ? public void updateStatistics(String tableName) throws SQLException
108

109 }
110
Popular Tags