Android Tutorial Remote Database Connector (RDC) - Connect to any remote DB

Status
Not open for further replies.

Stormer

New Member

Is there any way/tutorial how can I check the connection not to local database but to remote mysql database? For example, I have remote database
with
Host: myremotedb.com
User: my_user
Database Password: my_password
Port number: 3306

How need I change config-files or something else and what should I type in the address field of my browser to check that all is working correctly.
Please, help! Need it so much.
 

keirS

Well-Known Member
Licensed User
Longtime User
Is it possible to use the JDBC-ODBC bridge driver ("sun.jdbc.odbc.JdbcOdbcDriver") with RDC? The thing which is confusing me is that you say to copy the JDBC driver into the driver directory. The bridge diver is included in the Java Windows run time (RT.jar) and is already in the classpath.
 

persianpowerman1

Active Member
Licensed User
Longtime User
Can some one guide me... im stuck on the last step... checking the server from the browser...

RemoteServer is running (Sat Dec 07 21:25:25 IST 2013)
java.sql.SQLException: An attempt by a client to checkout a Connection has timed out.

and when i run the "animal" example.. i get this error...
Error: org.apache.http.conn.HttpHostConnectException: Connection to http://127.0.0.1:17178 refused

what is happening?? can someone please help me???
 

keirS

Well-Known Member
Licensed User
Longtime User
It should work. Note that Oracle do not recommend it for production use: http://docs.oracle.com/javase/1.5.0/docs/guide/jdbc/getstart/bridge.doc.html

You do not need to any any jar.

Thanks Erel . Got it working with a system DSN. A connection string doesn't work:

{Microsoft Visual FoxPro Driver};Collate=Machine; BackgroundFetch=Yes; Exclusive=No; SourceType=DBC; SourceDB=C:\testdb\data\projects.dbc

The RDC strips out the backslash characters for the SourceDB. None of the JDBC drivers for Visual Fox support stored procedures; triggers etc.
 

Gabino A. de la Gala

Active Member
Licensed User
Longtime User
¿Are there any way to know the type of fields obtained in the select querys?

I'd like to create a local database in runtime to store data locally. This database will be deteled/created each time to prevent posibles changes in the server part.

Is this posible?

In Spanish:

El obtener los datos y almacenarlos localmente ya lo tengo más/menos operativo, lo que estoy intentando conseguir ahora es que la creación de la tabla local no sea fija por programa, sino que se haga dinámicamente en función de los datos obtenidos del servidor, para así evitar tener que andar enviando actualizaciones del programa cada vez que retoque algo en las vistas y también me daría la posibilidad de crear una especie de librería para obtener datos y almacenarlos localmente.

Un saludo.
 

Gabino A. de la Gala

Active Member
Licensed User
Longtime User
Yes it is possible. The syntax finding the column data type is vendor specific. Why do you need it?

Don't you know the structure of the server database?
I'd like to do sometido universal.

I would like to prepare a method passing the name of the view (previously prepared in the server database) generate a local copy of that data.

This local copy would be created each time based on data from the view (this view may be modified at the server side without having to go to update the program of android devices)

The back shows the data in the android device will also "open" in the sense that the user could select the fields to display, sort that column, etc..
 

dibesw

Active Member
Licensed User
Longtime User
Hi,
I'm using very good jackaccess lib.
Is it possible manage the same mdb database with Remote Database Connector (RDC)?
If yes, where I can download correct JDBC driver (mdb/accdb database)?
Thanks
 
Last edited:

georgelbs

Member
Licensed User
Longtime User
I have the following code: (Database Oracle 11G):

Sub Sincroniza_Direcciones
Dim CUR As Cursor
Dim cmd, cmd1, cmd2, cmd3 As DBCommand
Dim consulta As String
Dim CLI_ID As Int
consulta="SELECT DISTINCT(CLI_ID) CLI_ID FROM mov_clientes ORDER BY CLI_ID"
CUR= SQL.ExecQuery(consulta)
If CUR.IsInitialized Then
DBUtils.DeleteAllRecord(SQL, "mov_direcciones")
DBUtils.DeleteAllRecord(SQL, "mov_telefonos")
DBUtils.DeleteAllRecord(SQL, "mov_referencias")
DBUtils.DeleteAllRecord(SQL, "mov_ult_gestiones")
cmd.Initialize
cmd1.Initialize
cmd2.Initialize
cmd3.Initialize
If CUR.RowCount> 0 Then
For i=0 To CUR.RowCount -1
CUR.Position = i
CLI_ID=CUR.GetInt("CLI_ID")
cmd.Name = "select_direcciones"
cmd.Parameters = Array As Object(CLI_ID)
reqManager.ExecuteQuery(cmd,0, "direcciones")
cmd1.Name = "select_telefonos"
cmd1.Parameters = Array As Object(CLI_ID)
reqManager.ExecuteQuery(cmd1,0, "telefonos")
' cmd2.Name = "select_referencias"
' cmd2.Parameters = Array As Object(CLI_ID)
' reqManager.ExecuteQuery(cmd2,0, "referencias")
' cmd3.Name = "select_ult_gestiones"
' cmd3.Parameters = Array As Object(CLI_ID)
' reqManager.ExecuteQuery(cmd3,0, "ultimas_gestiones")
Next
ProgressDialogHide
End If
CUR.Close
End If
End Sub

The code works but if I uncomment and try with 3 or more (reqManager.ExecuteQuery(cmdx,0, "xxxx") simply nothing happen, even the firsts 2 request aren´t executed. I tried combine the request1 with request3 commenting the 2 and so on, and works, but more than 2 requests simply don´t works.

Please put me on the right direction about this issue
 

georgelbs

Member
Licensed User
Longtime User
Please use [ code ] [ /code ] tags (without spaces) when posting code.

Where is the JobDone code? Do you get any error in the server logs?

Which server are you using?


None error in server logs, the server is Oracle 11G, I´m using the most update version of RDC server and client, the jobdone code is:

[ code ]
JobDone (job As httpjob)
Dim SQLtext As String
Dim req As HttpRequest
Dim cant, i As Int
Dim rs As Cursor
Dim filas1, ListaClientes, ListaActividades As List
'Dim ListaDirecciones, ListaTelefonos, ListaReferencias, ListaUltimasGestiones As List
Dim columnas As Map
If job.Success = False Then
Log("Error: " & job.ErrorMessage)
ToastMessageShow("Error en la conexión",False)
ProgressDialogHide
Else
If job.JobName = "DBRequest" Then
Dim result As DBResult = reqManager.HandleJob(job)
Dim datos() As String
Dim i As Int
Dim l As List
l.Initialize
i=0
filas1.Initialize
filas1 = result.Rows
columnas.Initialize
columnas=result.Columns
If filas1.IsInitialized Then
If filas1.Size <= 0 Then Return
End If
If columnas.IsInitialized Then
If columnas.Size <= 0 Then Return
End If
For Each row() As Object In result.Rows
For Each record As Object In row
l.add(record)
i=i+1
Next
Next
If job.Tag ="clientes" Then
' ToastMessageShow("Actualizando Clientes desde el servidor...", False)
ListaClientes.Initialize
ListaClientes.Clear
i=0
For Each row() As Object In result.Rows
Dim mClientes As Map
mClientes.Initialize
mClientes.Clear
mClientes.Put("AGE_ID",row(0))
mClientes.Put("AGE_AGENTE", row(1))
mClientes.Put("PLA_FECHA",row(2))
mClientes.Put("PLA_ID",row(3))
mClientes.Put("PLA_OBSERVACION", row(4))
mClientes.Put("GCO_ID",row(5))
mClientes.Put("ZON_ID",row(6))
mClientes.Put("ZON_ZONA", row(7))
mClientes.Put("CLI_ID",row(8))
mClientes.Put("CLI_NOMBRE",row(9))
mClientes.Put("CXC_ID", row(10))
mClientes.Put("CLO_NRO_VENCIMIENTO",row(11))
mClientes.Put("CLO_FECHA_VENCIMIENTO",row(12))
mClientes.Put("CLO_VALOR_CUOTA", row(13))
mClientes.Put("CLO_SALDO_CUOTA",row(14))
mClientes.Put("CLO_INT_MORA_GENERADO",row(15))
mClientes.Put("CLO_GTO_COB_GENERADO", row(16))
mClientes.Put("ITE_SKU_ID",row(17))
mClientes.Put("ITE_DESC_LARGA",row(18))
ListaClientes.Add(mClientes)
Next
DBUtils.InsertMaps(SQL, "mov_clientes", ListaClientes)
Sincroniza_Direcciones_Telefonos
End If
If job.Tag ="me" Then
If result.Rows.Size > 0 Then
Sincroniza_Oracle
Else
ToastMessageShow("No se puede conectar a la base de datos de Marcimex", False)
End If
End If
If job.Tag ="me1" Then
If result.Rows.Size > 0 Then
GetDatosCliente(Utils.CodigoVendedor)
Else
ToastMessageShow("No se puede conectar a la base de datos de Marcimex", False)
End If
End If
If job.Tag ="ACTIVIDADES" Then
Sincroniza_Verificaciones
End If
If job.Tag ="VERIFICACIONES" Then
ToastMessageShow("sincronizando clientes",False)
GetDatosCliente(Utils.CodigoVendedor)
End If
If job.Tag ="direcciones" Then
ListaDirecciones.Initialize
ListaDirecciones.Clear
For Each row() As Object In result.Rows
Dim mDirecciones As Map
mDirecciones.Initialize
mDirecciones.Clear
mDirecciones.Put("DIR_ID",row(0))
mDirecciones.Put("CLI_ID", row(1))
mDirecciones.Put("DIR_TIPO",row(2))
mDirecciones.Put("DIR_DESCRIPCION", row(3))
mDirecciones.Put("DIR_REF_UBICACION",row(4))
ListaDirecciones.Add(mDirecciones)
Next
DBUtils.InsertMaps(SQL, "mov_direcciones", ListaDirecciones)
End If
If job.Tag ="telefonos" Then
ListaTelefonos.Initialize
ListaTelefonos.Clear
For Each row() As Object In result.Rows
Dim mTelefonos As Map
mTelefonos.Initialize
mTelefonos.Clear
mTelefonos.Put("TEL_ID",row(0))
mTelefonos.Put("CLI_ID", row(1))
mTelefonos.Put("TEL_TIPO",row(2))
mTelefonos.Put("TEL_NUMERO", row(3))
ListaTelefonos.Add(mTelefonos)
Next
DBUtils.InsertMaps(SQL, "mov_telefonos", ListaTelefonos)
End If
If job.Tag ="referencias" Then
ListaReferencias.Initialize
ListaReferencias.Clear
For Each row() As Object In result.Rows
Dim mReferencias As Map
mReferencias.Initialize
mReferencias.Clear
mReferencias.Put("REF_ID",row(0))
mReferencias.Put("CLI_ID", row(1))
mReferencias.Put("RCL_TIPO",row(2))
mReferencias.Put("RCL_PRI_NOM", row(3))
mReferencias.Put("RCL_PRI_APE", row(4))
mReferencias.Put("RCL_TIP_TEL", row(5))
mReferencias.Put("RCL_TEL_NUM", row(6))
ListaReferencias.Add(mReferencias)
Next
DBUtils.InsertMaps(SQL, "mov_referencias", ListaReferencias)
End If
If job.Tag ="ultimas_gestiones" Then
ListaUltimasGestiones.Initialize
ListaUltimasGestiones.Clear
For Each row() As Object In result.Rows
Dim mUltimasGestiones As Map
mUltimasGestiones.Initialize
mUltimasGestiones.Clear
mUltimasGestiones.Put("ULG_ID",row(0))
mUltimasGestiones.Put("ULG_DESCIPCION",row(1))
mUltimasGestiones.Put("ULG_FECHA_GESTION", row(2))
mUltimasGestiones.Put("CLI_ID", row(3))
ListaUltimasGestiones.Add(mUltimasGestiones)
Next
DBUtils.InsertMaps(SQL, "mov_ult_gestiones", ListaUltimasGestiones)
ProgressDialogHide
End If
End If
End If
job.Release
End Sub
[ /code ]
 

Erel

B4X founder
Staff member
Licensed User
Longtime User

aklisiewicz

Active Member
Licensed User
Longtime User
Im getting errors on test, but I think it is because the configuration file expects SQL (not SQLite).
can you please post an example of configuration file for SQLite.

Arthur



 

aklisiewicz

Active Member
Licensed User
Longtime User
RemoteServer is running (Thu Dec 26 23:29:45 CST 2013)
java.sql.SQLException: An attempt by a client to checkout a Connection has timed out.

modified configuration file, and I see the server is runing but connection attempt fails.
Any ideas ?

URL: http://192.168.1.76:17178/?method=test


my config ->
--------------------------------------------------------
B4X:
#Lines starting with '#' are comments.
#Backslash character at the end of line means that the command continues in the next line.
#DriverClass=com.mysql.jdbc.Driver
#JdbcUrl=jdbc:mysql://localhost/test?characterEncoding=utf8

DriverClass=org.sqlite.JDBC
JdbcUrl=jdbc:sqlite:C:\DATA\PROJECTS_B4A\EDBQ_MOBILE\database\edbmo.db3

#SQL Server
#DriverClass=net.sourceforge.jtds.jdbc.Driver
#JdbcUrl=jdbc:jtds:sqlserver://<database server ip>/<database>
User=root
Password=
ServerPort=17178
#If Debug is true then this file will be reloaded on every query.
#This is useful if you need to modify the queries.
Debug=true

#commands
sql.create_table=CREATE TABLE animals (\
    id INT NOT NULL AUTO_INCREMENT,\
    name CHAR(30) NOT NULL,\
    image BLOB,\
    PRIMARY KEY (id))
sql.insert_animal=INSERT INTO animals VALUES (null, ?,?)
sql.select_animal=SELECT name, image FROM animals WHERE name = ?
 
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…