LAMW - ORACLE DB 11, 12c component lazarus / 43-Android ---------------------------------------------------------------------- Mongkey · 2024-07-13 09:26 Tutorial - OJDBC 8: certified with JDK 8, for Oracle database 11g and 12c. - OJDBC 10: certified with JDK 10, for Oracle database 18c and 19c. https://www.codejava.net/java-se/jdbc/connect-to-oracle-database-via- jdbc ---------------------------------------------------------------------- Mongkey · 2024-07-20 11:41 Code: Java  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i package org.lamw.test; import java.sql.Connection;import java.sql.DriverManager;import java.sql.SQLException; import java.util.Properties; import java.io.IOException;import java.sql.Connection;import java.sql.DriverManager;import java.sql.ResultSet;import java.sql.ResultSetMetaData;import java.sql.SQLException;import java.sql.Statement;  /** * This program demonstrates how to make database connection with Oracle * database server. * @author www.codejava.net * */   public class JdbcOracleConnection {    private static final String DEFAULT_URL = "jdbc:oracle:thin:@192.168.0.102:1521:oracle"; // Change IP_Address:Database    private static String DEFAULT_USERNAME;    private static String DEFAULT_PASSWORD;    private static String DEFAULT_SQL;    private static final String DEFAULT_DRIVER = "oracle.jdbc.driver.OracleDriver";     /**     * URL to connect database     */     public static Connection createConnection(String driver, String url, String username, String password) throws ClassNotFoundException, SQLException {        Class.forName(driver);      return DriverManager.getConnection(url, username, password);    }      public static void main(String[] args) {        Connection conn = null;        try {            // registers Oracle JDBC driver - though this is no longer required            // since JDBC 4.0, but added here for backward compatibility            //------1st METHOD          //Class.forName("oracle.jdbc.OracleDriver");             //Properties properties = new Properties();            //properties.put("user", DEFAULT_USERNAME);            //properties.put("password", DEFAULT_PASSWORD);            //properties.put("defaultRowPrefetch", "20");            //conn = DriverManager.getConnection(DEFAULT_URL, properties);            //------2nd METHOD            conn  = createConnection(DEFAULT_DRIVER, DEFAULT_URL,DEFAULT_USERNAME,DEFAULT_PASSWORD);             if (conn != null) {                System.out.println("Connected with oracle connection");                Statement stmt = conn.createStatement();                StringBuilder stringBuilder = new StringBuilder();                                              /*                                Executing Query for get Data                                 */                ResultSet rs = stmt.executeQuery(DEFAULT_SQL); // write your table name here..                                 /*                                Getting MetaData                                 */                ResultSetMetaData rsmd = rs.getMetaData();              int columnsNumber = rsmd.getColumnCount();                // print column names                for (int i = 1; i <= columnsNumber; i++) {//                    TextView textView = new TextView(context);//                    textView.setText(getString(R.s tring.tab).concat(rsmd.getColumnName(i)).concat(getString(R.string.tab )));//                    textView.setLayoutParams(rowParams);// TableRow is the parent view//                    textView.setTypeface(textView.getTypeface(), Typeface.BOLD);//                  tableRow.addView(textView);                } //              tableLayout.addView(tableRow);                                 /*                                  Getting each row                               */                while (rs.next()) {//                    TableRow tableRow1 = new TableRow(context);//                    tableRow1.setLayoutParams(rowParams);// TableLayout is the parent view                                         /*                                        Getting Columns                                       */                    for (int i = 1; i <= columnsNumber; i++) {                      String columnValue = rs.getString(i);                      stringBuilder.append(columnValue); //                        TextView textView = new TextView(context);//                        t extView.setText(getString(R.string.tab).concat(columnValue).concat(get String(R.string.tab)));//                        textView.setLayoutParams(rowParams);// TableRow is the parent view//                      tableRow1.addView(textView);                    }                    /* Adding into Table *///                    tableLayout.addView(tableRow1);                }                              /*                                  Closing connection.                               */                conn.close();    }      } catch (ClassNotFoundException ex) {            ex.printStackTrace();        } catch (SQLException ex) {            ex.printStackTrace();        } finally {            try {              if (conn != null && !conn.isClosed()) {                    conn.close();                }            } catch (SQLException ex) {                ex.printStackTrace();            }        }    }}  Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i unit ujdbcoracleconnection; {$mode delphi} interface uses  Classes, SysUtils, And_jni, {And_jni_Bridge,} AndroidWidget; type {Draft Component code by "LAMW: Lazarus Android Module Wizard" [7/21/2024 7:34:18 AM]}{https://github.com/jmpessoa/lazandroidmodulewizard} {jControl template} JdbcOracleConnection = class(jControl) private  public    constructor Create(AOwner: TComponent); override;    destructor  Destroy; override;    procedure Init; override;    procedure main(var args: TDynArrayOfString);  published end; procedure JdbcOracleConnection_main(env: PJNIEnv; _jdbcoracleconnection: JObject; var args: TDynArrayOfString);  implementation {---------  JdbcOracleConnection  --------------} constructor JdbcOracleConnection.Create(AOwner: TComponent);begin  inherited Create(AOwner);//your code here....end; destructor JdbcOracleConnection.Destroy;begin  if not (csDesigning in ComponentState) then  begin     if FjObject <> nil then     begin     jFree();       FjObject:= nil;     end;  end;  //you others free code here...'  inherited Destroy;end; procedure JdbcOracleConnection.Init;begin   if FInitialized  then Exit;  inherited Init; //set default ViewParent/FjPRLayout as jForm.View!  //your code here: set/initialize create params....  FjObject := jCreate(); //jSelf !   if FjObject = nil then exit;   FInitialized:= True;end;  procedure JdbcOracleConnection.main(var args: TDynArrayOfString);begin  //in designing component state: set value here...  if FInitialized then     JdbcOracleConnection_main(gApp.jni.jEnv, FjObject, args);end; {-------- JdbcOracleConnection_JNI_Bridge ----------} procedure JdbcOracleConnection_main(env: PJNIEnv; _jdbcoracleconnection: JObject; var args: TDynArrayOfString);var  jParams: array[0..0] of jValue;  jMethod: jMethodID=nil;  jCls: jClass=nil;  newSize0: integer;  jNewArray0: jObject=nil;  i: integer;label  _exceptionOcurred;begin   if (env = nil) or (_jdbcoracleconnection = nil) then exit;  jCls:= env^.GetObjectClass(env, _jdbcoracleconnection);  if jCls = nil then goto _exceptionOcurred;  jMethod:= env^.GetMethodID(env, jCls, 'main', '([Ljava/lang/String;)V');  if jMethod = nil then begin env^.DeleteLocalRef(env, jCls); goto _exceptionOcurred; end;   newSize0:= ?; //Length(?);  jNewArray0:= env^.NewObjectArray(env, newSize0, env^.FindClass(env,'java/lang/String'),env^.NewStringUTF(env, PChar('')));  for i:= 0 to newSize0 - 1 do  begin     env^.SetObjectArrayElement(env,jNewArray0,i,env^.NewStringUTF(env, PChar(args[i])));  end;  jParams[0].l:= jNewArray0;   env^.CallVoidMethodA(env, _jdbcoracleconnection, jMethod, @jParams);env^.DeleteLocalRef(env,jParams[0].l);   env^.DeleteLocalRef(env, jCls);   _exceptionOcurred: jni_ExceptionOccurred(env);end;   end. ---------------------------------------------------------------------- Mongkey · 2024-07-20 11:42 ojdbc14.jar file http://www.java2s.com/Code/JarDownload/ojdbc14/ojdbc14.jar.zip