Package com.kuzudb
Class Connection
java.lang.Object
com.kuzudb.Connection
Connection is used to interact with a Database instance. Each Connection is thread-safe. Multiple
connections can connect to the same Database instance in a multi-threaded environment.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
destroy()
Destroy the connection.execute
(PreparedStatement ps, Map<String, Value> m) Executes the given prepared statement with args and returns the result.protected void
finalize()
Finalize.long
Return the maximum number of threads used for execution in the current connection.void
Interrupts all queries currently executed within this connection.Prepares the given query and returns the prepared statement.Executes the given query and returns the result.void
setMaxNumThreadForExec
(long numThreads) Sets the maximum number of threads to use for execution in the current connection.void
setQueryTimeout
(long timeoutInMs) Sets the query timeout value of the current connection.
-
Constructor Details
-
Connection
Creates a connection to the database.- Parameters:
db
- : Database instance.
-
-
Method Details
-
finalize
Finalize.- Overrides:
finalize
in classObject
- Throws:
ObjectRefDestroyedException
- If the connection has been destroyed.
-
destroy
Destroy the connection.- Throws:
ObjectRefDestroyedException
- If the connection has been destroyed.
-
getMaxNumThreadForExec
Return the maximum number of threads used for execution in the current connection.- Returns:
- The maximum number of threads used for execution in the current connection.
- Throws:
ObjectRefDestroyedException
- If the connection has been destroyed.
-
setMaxNumThreadForExec
Sets the maximum number of threads to use for execution in the current connection.- Parameters:
numThreads
- : The maximum number of threads to use for execution in the current connection- Throws:
ObjectRefDestroyedException
- If the connection has been destroyed.
-
query
Executes the given query and returns the result.- Parameters:
queryStr
- : The query to execute.- Returns:
- The result of the query.
- Throws:
ObjectRefDestroyedException
- If the connection has been destroyed.
-
prepare
Prepares the given query and returns the prepared statement.- Parameters:
queryStr
- : The query to prepare.- Returns:
- The prepared statement.
- Throws:
ObjectRefDestroyedException
- If the connection has been destroyed.
-
execute
public QueryResult execute(PreparedStatement ps, Map<String, Value> m) throws ObjectRefDestroyedExceptionExecutes the given prepared statement with args and returns the result.- Parameters:
ps
- : The prepared statement to execute.m
- : The parameter pack where each arg is a std::pair with the first element being parameter name and second element being parameter value- Returns:
- The result of the query.
- Throws:
ObjectRefDestroyedException
- If the connection has been destroyed.
-
interrupt
Interrupts all queries currently executed within this connection.- Throws:
ObjectRefDestroyedException
- If the connection has been destroyed.
-
setQueryTimeout
Sets the query timeout value of the current connection. A value of zero (the default) disables the timeout.- Parameters:
timeoutInMs
- : The query timeout value in milliseconds.- Throws:
ObjectRefDestroyedException
- If the connection has been destroyed.
-