1 | /* |
2 | |
3 | Derby - Class org.apache.derby.client.net.NetSqlca |
4 | |
5 | Copyright (c) 2001, 2005 The Apache Software Foundation or its licensors, where applicable. |
6 | |
7 | Licensed under the Apache License, Version 2.0 (the "License"); |
8 | you may not use this file except in compliance with the License. |
9 | You may obtain a copy of the License at |
10 | |
11 | http://www.apache.org/licenses/LICENSE-2.0 |
12 | |
13 | Unless required by applicable law or agreed to in writing, software |
14 | distributed under the License is distributed on an "AS IS" BASIS, |
15 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
16 | See the License for the specific language governing permissions and |
17 | limitations under the License. |
18 | |
19 | */ |
20 | |
21 | package org.apache.derby.client.net; |
22 | |
23 | import org.apache.derby.client.am.Sqlca; |
24 | import org.apache.derby.shared.common.reference.SQLState; |
25 | import org.apache.derby.client.am.ClientMessageId; |
26 | import org.apache.derby.client.am.SqlException; |
27 | import java.io.UnsupportedEncodingException; |
28 | |
29 | public class NetSqlca extends Sqlca { |
30 | // these are the same variables that are in the Sqlca except ccsids |
31 | // are a little different |
32 | |
33 | NetSqlca(org.apache.derby.client.am.Connection connection, |
34 | int sqlCode, |
35 | String sqlState, |
36 | byte[] sqlErrpBytes) { |
37 | super(connection); |
38 | sqlCode_ = sqlCode; |
39 | sqlState_ = sqlState; |
40 | sqlErrpBytes_ = sqlErrpBytes; |
41 | } |
42 | |
43 | NetSqlca(org.apache.derby.client.am.Connection connection, |
44 | int sqlCode, |
45 | byte[] sqlState, |
46 | byte[] sqlErrpBytes) throws SqlException { |
47 | super(connection); |
48 | sqlCode_ = sqlCode; |
49 | try |
50 | { |
51 | sqlState_ = bytes2String(sqlState,0,sqlState.length); |
52 | }catch(UnsupportedEncodingException uee) |
53 | { |
54 | throw new SqlException(null, |
55 | new ClientMessageId(SQLState.UNSUPPORTED_ENCODING), |
56 | "sqlstate bytes", "SQLSTATE",uee); |
57 | } |
58 | sqlErrpBytes_ = sqlErrpBytes; |
59 | } |
60 | protected void setSqlerrd(int[] sqlErrd) { |
61 | sqlErrd_ = sqlErrd; |
62 | } |
63 | |
64 | protected void setSqlwarnBytes(byte[] sqlWarnBytes) { |
65 | sqlWarnBytes_ = sqlWarnBytes; |
66 | } |
67 | |
68 | protected void setSqlerrmcBytes(byte[] sqlErrmcBytes, int sqlErrmcCcsid) { |
69 | sqlErrmcBytes_ = sqlErrmcBytes; |
70 | sqlErrmcCcsid_ = sqlErrmcCcsid; |
71 | } |
72 | |
73 | public long getRowCount(Typdef typdef) throws org.apache.derby.client.am.DisconnectException { |
74 | int byteOrder = typdef.getByteOrder(); |
75 | long num = (byteOrder == org.apache.derby.client.am.SignedBinary.BIG_ENDIAN) ? |
76 | super.getRowCount() : ((long) sqlErrd_[1] << 32) + sqlErrd_[0]; |
77 | return num; |
78 | } |
79 | } |