File D:\maven-qcr-plugin-testsunitaires\qcr4java\h2-1.3.170-sources\target\site\qc\lecode\engine\SessionInterface.java.html

1 /*
2 * Copyright 2004-2011 H2 Group. Multiple-Licensed under the H2 License,
3 * Version 1.0, and under the Eclipse Public License, Version 1.0
4 * (http://h2database.com/html/license.html).
5 * Initial Developer: H2 Group
6 */
7 package org.h2.engine;
8
9 import java.io.Closeable;
10 import org.h2.command.CommandInterface;
11 import org.h2.message.Trace;
12 import org.h2.store.DataHandler;
13
14 /**
15 * A local or remote session. A session represents a database connection.
16 */
17 public interface SessionInterface extends Closeable {
18
19 /**
20 * Parse a command and prepare it for execution.
21 *
22 * @param sql the SQL statement
23 * @param fetchSize the number of rows to fetch in one step
24 * @return the prepared command
25 */
26 CommandInterface prepareCommand(String sql, int fetchSize);
27
28 /**
29 * Roll back pending transactions and close the session.
30 */
31 void close();
32
33 /**
34 * Get the trace object
35 *
36 * @return the trace object
37 */
38 Trace getTrace();
39
40 /**
41 * Check if close was called.
42 *
43 * @return if the session has been closed
44 */
45 boolean isClosed();
46
47 /**
48 * Get the number of disk operations before power failure is simulated.
49 * This is used for testing. If not set, 0 is returned
50 *
51 * @return the number of operations, or 0
52 */
53 int getPowerOffCount();
54
55 /**
56 * Set the number of disk operations before power failure is simulated.
57 * To disable the countdown, use 0.
58 *
59 * @param i the number of operations
60 */
61 void setPowerOffCount(int i);
62
63 /**
64 * Get the data handler object.
65 *
66 * @return the data handler
67 */
68 DataHandler getDataHandler();
69
70 /**
71 * Get the undo log position.
72 *
73 * @return the position (0 means no pending transaction)
74 */
75 int getUndoLogPos();
76
77 /**
78 * Cancel the current or next command (called when closing a connection).
79 */
80 void cancel();
81
82 /**
83 * Check if the database changed and therefore reconnecting is required.
84 *
85 * @param write if the next operation may be writing
86 * @return true if reconnecting is required
87 */
88 boolean isReconnectNeeded(boolean write);
89
90 /**
91 * Close the connection and open a new connection.
92 *
93 * @param write if the next operation may be writing
94 * @return the new connection
95 */
96 SessionInterface reconnect(boolean write);
97
98 /**
99 * Called after writing has ended. It needs to be called after
100 * isReconnectNeeded(true) returned false.
101 */
102 void afterWriting();
103
104 /**
105 * Check if this session is in auto-commit mode.
106 *
107 * @return true if the session is in auto-commit mode
108 */
109 boolean getAutoCommit();
110
111 /**
112 * Set the auto-commit mode. This call doesn't commit the current
113 * transaction.
114 *
115 * @param autoCommit the new value
116 */
117 void setAutoCommit(boolean autoCommit);
118
119 }
120