B4J Code Snippet Connecting to Oracle using jSQL

For more info on Oracle and B4J go here.

B4X:
#Region  Project Attributes
   #MainFormWidth: 600
   #MainFormHeight: 400
   #AdditionalJar: ojdbc7.jar
End Region

Sub Process_Globals
   Private fx As JFX
   Private MainForm As Form
   Dim conn As SQL
End Sub

Sub AppStart (Form1 As Form, Args() As String)
   MainForm = Form1
   conn.InitializeAsync("conn", "oracle.jdbc.driver.OracleDriver", _
          "jdbc:oracle:thin:@//localhost:1521/MyDB","SCOTT","tiger")
   MainForm.Show
End Sub

Sub conn_Ready (Success As Boolean)
   If Success = False Then
      Log(LastException)
      Return
   End If

   Dim rs As ResultSet = conn.ExecQuery("SELECT sysdate FROM dual")
   Do While rs.NextRow
      Log(rs.GetString2(0))
   Loop
   rs.Close
End Sub
 
Top