B4J Question jSQL - Insert record

besoft

Active Member
Licensed User
Longtime User
I have the following question:
I am using jSql to work with Oracle database. Connects successfully. Even a successful refill the table with data.
How to run a query for Insert record.
Do I always have to re-connect to the Oracle database for each query?

Conn string:

B4X:
conn.InitializeAsync("conn", "oracle.jdbc.driver.OracleDriver", _
          "jdbc:oracle:thin:@//localhost:1521/xe","hr","xxxx")

What is the best technique to establish connections with databases?

Is it good to connect to the database at application startup? Does the connection is established at the request button?
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
Do I always have to re-connect to the Oracle database for each query?
No.

ConnectionPool (from the jServer library) is very useful when connecting to remote databases. It will handle the remote connections automatically.
This way you won't need to handle broken connections.

You just need to initialize it and the call GetConnection to get the SQL object and call Close to return it to the pool.
 
Upvote 0

besoft

Active Member
Licensed User
Longtime User
To insert records into the database use:

B4X:
conn.ExecQueryAsync("SQL","insert into test (test, memo) values ('bla bla', 'memo')",Null)

Is this method correct?
What does it mean parameter Null in the end?

Currently I have a problem with the selection of lines in tableview. I need information from the selected row in the text field. Do you have any advice?
 
Upvote 0

eurojam

Well-Known Member
Licensed User
Longtime User
the NULL means, that you don't pass arguments to the query, something like
B4X:
conn.ExecQueryAsync(  "SQL","insert into test (test, memo) values (?,?)",Array As String("bla bla", "memo"))
 
Upvote 0
Top