Documentation
¶
Index ¶
- Constants
- type DaemonServer
- type JobPool
- func (jp *JobPool) AddJob(s *SQLJob) error
- func (jp *JobPool) Close()
- func (jp *JobPool) ExecuteSQL(sql string) (*ServerResponse, error)
- func (jp *JobPool) ExecuteSQLWithOptions(command string, queryops QueryOptions) (*ServerResponse, error)
- func (jp *JobPool) GetJob() (s *SQLJob, err error)
- func (jp *JobPool) GetJobCount() int
- type PoolOptions
- type Query
- type QueryOptions
- type SQLJob
- func (s *SQLJob) ClCommand(command string) (*Query, error)
- func (s *SQLJob) Close() error
- func (s *SQLJob) Connect(server DaemonServer) error
- func (s *SQLJob) GetStatus() string
- func (s *SQLJob) GetTraceData() error
- func (s *SQLJob) GetVersion() (string, error)
- func (s *SQLJob) Query(sql string) (*Query, error)
- func (s *SQLJob) QueryWithOptions(command string, options QueryOptions) (*Query, error)
- func (s *SQLJob) SetTraceConfig(ops TraceOptions) error
- type ServerError
- type ServerResponse
- type TraceOptions
- type WebsocketError
Constants ¶
const ( STATE_RUN_DONE = iota STATE_RUN_MORE_DATA STATE_NOT_YET_RUN )
const ( JOBSTATUS_BUSY = "BUSY" JOBSTATUS_ERROR = "ERROR" JOBSTATUS_ENDED = "ENDED" JOBSTATUS_READY = "READY" JOBSTATUS_CONNECTING = "CONNECTING" JOBSTATUS_NOT_STARTED = "NOT_STARTED" )
const ( DEFAULT_FETCH_SIZE = 100 MAX_FETCH_SIZE = 1000 )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DaemonServer ¶
type DaemonServer struct { Host string // Hostname or IP User string // Username for authentication Password string // Password for authentication Port string // Default port is 8076 Technique string // CLI or TCP Properties string // A semicolon-delimited list of JDBC connection properties }
Represents a DB2 server daemon with connection details.
type JobPool ¶
type JobPool struct {
// contains filtered or unexported fields
}
Connection pool
func (*JobPool) ExecuteSQL ¶
func (jp *JobPool) ExecuteSQL(sql string) (*ServerResponse, error)
Execute a SQL query with a job from the pool
func (*JobPool) ExecuteSQLWithOptions ¶
func (jp *JobPool) ExecuteSQLWithOptions(command string, queryops QueryOptions) (*ServerResponse, error)
Execute a SQL query with options, using a job from the pool
func (*JobPool) GetJobCount ¶
Receive the count of jobs that have been initialized by the pool
type PoolOptions ¶
type PoolOptions struct { Creds DaemonServer // Credentials to connect to the server MaxWaitTime int // Max time to wait for a job (in seconds) MaxSize int // Pool max size StartingSize int // Pool starting count }
Represents the options for configuring a connection pool
type Query ¶
type Query struct { ID string // The unique identifier // contains filtered or unexported fields }
Represents a SQL Query that can be executed and managed within a SQL job
func (*Query) Execute ¶
func (q *Query) Execute() (*ServerResponse, error)
Executes the query/command and returns the results
type QueryOptions ¶
type QueryOptions struct { Rows int // The amount of rows to fetch Parameters [][]any // Parameters, if any TerseResult bool // Whether the result returns in terse format IsCLcommand bool // Whether the command is a CL command }
Represents options for query execution
type SQLJob ¶
type SQLJob struct { ID string // Unique identifier Jobname string // Name of the Job Status string // Status of the Job Options *TraceOptions // Trace configuration options // contains filtered or unexported fields }
Represents a SQL job that manages connections and queries to a database.
func (*SQLJob) Connect ¶
func (s *SQLJob) Connect(server DaemonServer) error
Creates a websocket connection and connects to the server.
func (*SQLJob) GetTraceData ¶
Receive trace data (after setting config)
func (*SQLJob) GetVersion ¶
Receive the current version info
func (*SQLJob) QueryWithOptions ¶
func (s *SQLJob) QueryWithOptions(command string, options QueryOptions) (*Query, error)
Creates a query with the given options
func (*SQLJob) SetTraceConfig ¶
func (s *SQLJob) SetTraceConfig(ops TraceOptions) error
Set trace configuration options
type ServerError ¶ added in v0.1.4
func (*ServerError) Error ¶ added in v0.1.4
func (e *ServerError) Error() string
type ServerResponse ¶
type ServerResponse struct { ID string // The unique identifier of the request Job string // The name of the DB Job Success bool // Whether the request was successful Metadata *metadata Data []map[string]interface{} TerseData [][]any `json:"terse_data"` // Data in terse format if specified HasResults bool `json:"has_results"` // Whether the response has results IsDone bool `json:"is_done"` // Whether the query execution is complete ParameterCount int `json:"parameter_count"` // The number of parameters in the prepared query UpdateCount int `json:"update_count"` // The number of rows affected by the query (returns -1 if none) Error error // The error message, if any SqlState string // The SQL state code SqlRC int // The SQL error code }
Represents the server response.
type TraceOptions ¶
type TraceOptions struct { Tracelevel string // OFF, ON, ERRORS, DATASTREAM, INPUT_AND_ERRORS Tracedest string // One of (file, in_mem) Jtopentracelevel string // OFF, ON, ERRORS, DATASTREAM, INPUT_AND_ERRORS Jtopentracedest string // One of (file, in_mem) // contains filtered or unexported fields }
Represents trace configuration options
type WebsocketError ¶ added in v0.1.4
func (*WebsocketError) Error ¶ added in v0.1.4
func (e *WebsocketError) Error() string