01: /*
02:
03: Derby - Class org.apache.derby.client.net.NetSqlca
04:
05: Licensed to the Apache Software Foundation (ASF) under one or more
06: contributor license agreements. See the NOTICE file distributed with
07: this work for additional information regarding copyright ownership.
08: The ASF licenses this file to You under the Apache License, Version 2.0
09: (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;
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, String sqlState, byte[] sqlErrpBytes) {
36: super (connection);
37: sqlCode_ = sqlCode;
38: sqlState_ = sqlState;
39: sqlErrpBytes_ = sqlErrpBytes;
40: }
41:
42: NetSqlca(org.apache.derby.client.am.Connection connection,
43: int sqlCode, byte[] sqlState, byte[] sqlErrpBytes)
44: throws SqlException {
45: super (connection);
46: sqlCode_ = sqlCode;
47: try {
48: sqlState_ = bytes2String(sqlState, 0, sqlState.length);
49: } catch (UnsupportedEncodingException uee) {
50: throw new SqlException(null, new ClientMessageId(
51: SQLState.UNSUPPORTED_ENCODING), "sqlstate bytes",
52: "SQLSTATE", uee);
53: }
54: sqlErrpBytes_ = sqlErrpBytes;
55: }
56:
57: protected void setSqlerrd(int[] sqlErrd) {
58: sqlErrd_ = sqlErrd;
59: }
60:
61: protected void setSqlwarnBytes(byte[] sqlWarnBytes) {
62: sqlWarnBytes_ = sqlWarnBytes;
63: }
64:
65: protected void setSqlerrmcBytes(byte[] sqlErrmcBytes,
66: int sqlErrmcCcsid) {
67: sqlErrmcBytes_ = sqlErrmcBytes;
68: sqlErrmcCcsid_ = sqlErrmcCcsid;
69: }
70:
71: public long getRowCount(Typdef typdef)
72: throws org.apache.derby.client.am.DisconnectException {
73: int byteOrder = typdef.getByteOrder();
74: long num = (byteOrder == org.apache.derby.client.am.SignedBinary.BIG_ENDIAN) ? super
75: .getRowCount()
76: : ((long) sqlErrd_[1] << 32) + sqlErrd_[0];
77: return num;
78: }
79: }
|