KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > derby > client > net > NetSqlca


1 /*
2
3    Derby - Class org.apache.derby.client.net.NetSqlca
4
5    Licensed to the Apache Software Foundation (ASF) under one or more
6    contributor license agreements. See the NOTICE file distributed with
7    this work for additional information regarding copyright ownership.
8    The ASF licenses this file to You under the Apache License, Version 2.0
9    (the "License"); you may not use this file except in compliance with
10    the License. You may obtain a copy of the License at
11
12       http://www.apache.org/licenses/LICENSE-2.0
13
14    Unless required by applicable law or agreed to in writing, software
15    distributed under the License is distributed on an "AS IS" BASIS,
16    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17    See the License for the specific language governing permissions and
18    limitations under the License.
19
20 */

21
22 package org.apache.derby.client.net;
23
24 import org.apache.derby.client.am.Sqlca;
25 import org.apache.derby.shared.common.reference.SQLState;
26 import org.apache.derby.client.am.ClientMessageId;
27 import org.apache.derby.client.am.SqlException;
28 import java.io.UnsupportedEncodingException JavaDoc;
29
30 public class NetSqlca extends Sqlca {
31     // these are the same variables that are in the Sqlca except ccsids
32
// are a little different
33

34     NetSqlca(org.apache.derby.client.am.Connection connection,
35              int sqlCode,
36              String JavaDoc sqlState,
37              byte[] sqlErrpBytes) {
38         super(connection);
39         sqlCode_ = sqlCode;
40         sqlState_ = sqlState;
41         sqlErrpBytes_ = sqlErrpBytes;
42     }
43
44     NetSqlca(org.apache.derby.client.am.Connection connection,
45             int sqlCode,
46             byte[] sqlState,
47             byte[] sqlErrpBytes) throws SqlException {
48        super(connection);
49        sqlCode_ = sqlCode;
50        try
51        {
52            sqlState_ = bytes2String(sqlState,0,sqlState.length);
53        }catch(UnsupportedEncodingException JavaDoc uee)
54        {
55             throw new SqlException(null,
56                   new ClientMessageId(SQLState.UNSUPPORTED_ENCODING),
57                        "sqlstate bytes", "SQLSTATE",uee);
58        }
59        sqlErrpBytes_ = sqlErrpBytes;
60    }
61     protected void setSqlerrd(int[] sqlErrd) {
62         sqlErrd_ = sqlErrd;
63     }
64
65     protected void setSqlwarnBytes(byte[] sqlWarnBytes) {
66         sqlWarnBytes_ = sqlWarnBytes;
67     }
68
69     protected void setSqlerrmcBytes(byte[] sqlErrmcBytes, int sqlErrmcCcsid) {
70         sqlErrmcBytes_ = sqlErrmcBytes;
71         sqlErrmcCcsid_ = sqlErrmcCcsid;
72     }
73
74     public long getRowCount(Typdef typdef) throws org.apache.derby.client.am.DisconnectException {
75         int byteOrder = typdef.getByteOrder();
76         long num = (byteOrder == org.apache.derby.client.am.SignedBinary.BIG_ENDIAN) ?
77                 super.getRowCount() : ((long) sqlErrd_[1] << 32) + sqlErrd_[0];
78         return num;
79     }
80 }
81
Popular Tags