01: /*
02:
03: Derby - Class org.apache.derby.impl.tools.ij.AsyncStatement
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.impl.tools.ij;
23:
24: import java.sql.Connection;
25: import java.sql.Statement;
26: import java.sql.SQLException;
27:
28: //import java.io.PrintStream;
29:
30: class AsyncStatement extends Thread {
31: Connection conn;
32: String stmt;
33: ijResult result;
34:
35: AsyncStatement(Connection theConn, String theStmt) {
36: conn = theConn;
37: stmt = theStmt;
38: }
39:
40: public void run() {
41: Statement aStatement = null;
42: try {
43: aStatement = conn.createStatement();
44: aStatement.execute(stmt);
45: result = new ijStatementResult(aStatement, true);
46: // caller must release its resources
47: } catch (SQLException e) {
48: result = new ijExceptionResult(e);
49: if (aStatement != null)
50: try {
51: aStatement.close();
52: } catch (SQLException e2) {
53: // not a lot we can do here...
54: }
55: }
56: aStatement = null;
57: }
58:
59: ijResult getResult() {
60: return result;
61: }
62: }
|