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

Status
Not open for further replies.

TomDuncan

Active Member
Licensed User
Longtime User
Or maybe use sqlite3 instead.
Big problem is file size. With the number of books we have the size might go to 5gig.

This does work well with postgres but with the hassles so far with bytea will have to think about what to do.

Tom
 

TomDuncan

Active Member
Licensed User
Longtime User
Will do some more testing in the morning with the bytea.
Changing the way it stores to the older escape type. (Beyond my knowledge of postgresql but will test)

Tom
 

patrick14384

Member
Licensed User
Longtime User
Ok, I am doing something simple wrong. Trying to get the server running, and I get

C:\Users\gallagher>"C:\Program Files (x86)\Java\jdk1.7.0_25\bin\java" -Xmx256m -
cp .;libs\*;jdbc_driver\* anywheresoftware.b4a.remotedatabase.RemoteServer
Error: Could not find or load main class anywheresoftware.b4a.remotedatabase.RemoteServer

Everything is local to this computer in my effort to start simple.

Not that I think this is the problem, but config.properties is
B4X:
DriverClass=org.postgresql.Driver
JdbcUrl=jdbc:mysql://localhost/test?characterEncoding=utf8

User=postgres
Password=mypassword
ServerPort=17178

Pretty sure I need to put something somewhere on the hard drive, but not sure what or where. Thanks for any help!

Patrick
 

alienhunter

Active Member
Licensed User
Longtime User
Or maybe use sqlite3 instead.
Big problem is file size. With the number of books we have the size might go to 5gig.

This does work well with postgres but with the hassles so far with bytea will have to think about what to do.

Tom

the way that i solved some problems is try to gzip the file and then upload it as blob in mysql /sqlite then you database will be smaller and quicker
when you download it for the database unzip it ....

save it as binary type
http://www.postgresql.org/docs/8.4/static/datatype-binary.html

The SQL standard defines a different binary string type, called BLOB or BINARY LARGE OBJECT. The input format is different from bytea, but the provided functions and operators are mostly the same.

looks like you have to store the binary different like in sql
 
Last edited:

alienhunter

Active Member
Licensed User
Longtime User
batch command

Hi Erel , i could not figure out how to send let say 1000 commands at the same time
example

update row 1 col 1
update row 2 col 1
....
update row 1000 col1
and so on

how should this list be created /needed , i cannot find any example so far

B4X:
for i = 0  to 1000
parm1=(i)
parm2=(i)
ccd=cmd.Name = "update_touda"
list.add (ccd,parm1,parm2)
next
reqManager.ExecuteBatch(list,1)

?

thanks AH
 

opal

Member
Licensed User
Longtime User
Hello, I am new here.
So, I run server. In browser writed: http://127.0.0.1:17178/?method=test. Response OK: RemoteServer is running (Sun Nov 10 13:56:23 CET 2013)
Connection successful.

Next, part of my confige file - I use Pervasive SQL:
DriverClass=com.pervasive.jdbc.v2.Driver
JdbcUrl=jdbcervasive://localhost:1583/DEMODATA?transport=tcp

#commands
sql.create_table=CREATE TABLE animals (\
id CHAR(10) NOT NULL,\
name CHAR(30) NOT NULL,\
PRIMARY KEY (id))
sql.insert_animal=INSERT INTO animals VALUES (null, ?,?)
sql.select_animal=SELECT name, image FROM animals WHERE name = ?
sql.select_person=SELECT First_Name, Last_Name FROM Person

Then I run demo Remote Database Connector and execute Sub:
B4X:
Sub GetAnimal(Name As String)

    Dim cmd As DBCommand
    cmd.Initialize
    cmd.Name = "select_animal"
    cmd.Parameters = Array As Object(Name)
    reqManager.ExecuteQuery(cmd, 0, Null)
End Sub

and I get error: java.sql.SQLException: [LNA][Pervasive][ODBC Engine Interface][Data Record Manager]No such table or object.

correct, I haven't table animals. Then I execute Sub:
B4X:
Sub GetAnimal(Name As String)
    Dim cmd As DBCommand
    cmd.Initialize
    cmd.Name = "select_person"
    cmd.Parameters = Array As Object(Name)
    reqManager.ExecuteQuery(cmd, 0, Null)
End Sub

Table Person I have in database, but I get error:
java.sql.SQLException: Function not implemented
Error: Server Error

Same error I get if I run Sub:
B4X:
Sub btnCreateAnimals_Click
    Dim cmd As DBCommand
    cmd.Initialize
    cmd.Name = "create_table"
'    cmd.Parameters = Array As Object(Name)
    reqManager.ExecuteQuery(cmd, 0, Null)
End Sub

Can anybody help me ?
 

opal

Member
Licensed User
Longtime User
Where, or how I can get server log file ? I copy log from B4A and attached.
 

Attachments

  • something.zip
    37.1 KB · Views: 500

opal

Member
Licensed User
Longtime User
Server log (I hope):


c:\RemoteDatabaseConnector>"c:\Program Files (x86)\Java\jre7\bin\java" -Xmx256m
-cp .;libs\*;jdbc_driver\* anywheresoftware.b4a.remotedatabase.RemoteServer
B4A Remote Database Connecter (version 0.9)
loading: c:\RemoteDatabaseConnector\config.properties
2013-11-11 16:21:37.692:INFO::jetty-7.4.2.v20110526
2013-11-11 16:21:37.715:INFO::started o.e.j.s.ServletContextHandler{/,null}
nov 11, 2013 4:21:37 PM com.mchange.v2.log.MLog <clinit>
INFO: MLog clients using java 1.4+ standard logging.
nov 11, 2013 4:21:37 PM com.mchange.v2.c3p0.C3P0Registry banner
INFO: Initializing c3p0-0.9.2.1 [built 20-March-2013 11:16:28 +0000; debug? true
; trace: 10]
2013-11-11 16:21:37.930:INFO::Started SelectChannelConnector@0.0.0.0:17178 START
ING

I use Windows 8.
 

opal

Member
Licensed User
Longtime User
Sorry, I did not. You are the best. Here is new post. I executed first Sub:
B4X:
Sub GetAnimal(Name As String)
    Dim cmd As DBCommand
    cmd.Initialize
    cmd.Name = "select_animal"
    cmd.Parameters = Array As Object(Name)
    reqManager.ExecuteQuery(cmd, 0, Null)
End Sub

Table animal doesn't exist in database. Then I executed Sub:
B4X:
Sub btnCreateAnimals_Click
    Dim cmd As DBCommand
    cmd.Initialize
    cmd.Name = "create_table"
    reqManager.ExecuteQuery(cmd, 0, Null)
End Sub

Then I executed Sub:
B4X:
Sub GetAnimal(Name As String)
    Dim cmd As DBCommand
    cmd.Initialize
    cmd.Name = "select_person"
    cmd.Parameters = Array As Object(Name)
    reqManager.ExecuteQuery(cmd, 0, Null)
End Sub

Table Person exist in database.

Server log (see message: Function not implemented):

c:\RemoteDatabaseConnector>"c:\Program Files (x86)\Java\jre7\bin\java" -Xmx256m
-cp .;libs\*;jdbc_driver\* anywheresoftware.b4a.remotedatabase.RemoteServer
B4A Remote Database Connecter (version 0.9)
loading: c:\RemoteDatabaseConnector\config.properties
2013-11-11 19:39:15.966:INFO::jetty-7.4.2.v20110526
2013-11-11 19:39:15.990:INFO::started o.e.j.s.ServletContextHandler{/,null}
nov 11, 2013 7:39:16 PM com.mchange.v2.log.MLog <clinit>
INFO: MLog clients using java 1.4+ standard logging.
nov 11, 2013 7:39:16 PM com.mchange.v2.c3p0.C3P0Registry banner
INFO: Initializing c3p0-0.9.2.1 [built 20-March-2013 11:16:28 +0000; debug? true
; trace: 10]
2013-11-11 19:39:16.203:INFO::Started SelectChannelConnector@0.0.0.0:17178 START
ING
nov 11, 2013 7:40:49 PM com.mchange.v2.c3p0.impl.AbstractPoolBackedDataSource ge
tPoolManager
INFO: Initializing c3p0 pool... com.mchange.v2.c3p0.ComboPooledDataSource [ acqu
ireIncrement -> 3, acquireRetryAttempts -> 30, acquireRetryDelay -> 1000, autoCo
mmitOnClose -> false, automaticTestTable -> null, breakAfterAcquireFailure -> fa
lse, checkoutTimeout -> 20000, connectionCustomizerClassName -> null, connection
TesterClassName -> com.mchange.v2.c3p0.impl.DefaultConnectionTester, dataSourceN
ame -> 1hge0z88yk3sdwag4zill|18806f7, debugUnreturnedConnectionStackTraces -> fa
lse, description -> null, driverClass -> com.pervasive.jdbc.v2.Driver, factoryCl
assLocation -> null, forceIgnoreUnresolvedTransactions -> false, identityToken -
> 1hge0z88yk3sdwag4zill|18806f7, idleConnectionTestPeriod -> 600, initialPoolSiz
e -> 3, jdbcUrl -> jdbcervasive://localhost:1583/DEMODATA?transport=tcp, maxAd
ministrativeTaskTime -> 0, maxConnectionAge -> 0, maxIdleTime -> 1800, maxIdleTi
meExcessConnections -> 0, maxPoolSize -> 15, maxStatements -> 150, maxStatements
PerConnection -> 0, minPoolSize -> 3, numHelperThreads -> 3, preferredTestQuery
-> null, properties -> {user=******, password=******}, propertyCycle -> 0, state
mentCacheNumDeferredCloseThreads -> 0, testConnectionOnCheckin -> false, testCon
nectionOnCheckout -> false, unreturnedConnectionTimeout -> 0, userOverrides -> {
}, usesTraditionalReflectiveProxies -> false ]
java.sql.SQLException: [LNA][Pervasive][ODBC Engine Interface][Data Record Manag
er]No such table or object.
at com.pervasive.jdbc.lna.LNAObject.getErrors(LNAObject.java:213)
at com.pervasive.jdbc.lna.LNAStatement.getErrors(LNAStatement.java:937)
at com.pervasive.jdbc.lna.LNAObject.checkError(LNAObject.java:256)
at com.pervasive.jdbc.lna.LNAStatement.prepare(LNAStatement.java:273)
at com.pervasive.jdbc.v2.PreparedStatement.<init>(PreparedStatement.java
:54)
at com.pervasive.jdbc.v2.Connection.prepareStatement(Connection.java:539
)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at com.mchange.v2.c3p0.stmt.GooGooStatementCache$1StmtAcquireTask.run(Go
oGooStatementCache.java:546)
at com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread.run(Thre
adPoolAsynchronousRunner.java:648)
java.sql.SQLException: Function not implemented
at com.pervasive.jdbc.v2.PreparedStatement.getParameterMetaData(Prepared
Statement.java:653)
at com.mchange.v2.c3p0.impl.NewProxyPreparedStatement.getParameterMetaDa
ta(NewProxyPreparedStatement.java:303)
at anywheresoftware.b4a.remotedatabase.Servlet.createStatement(Servlet.j
ava:178)
at anywheresoftware.b4a.remotedatabase.Servlet.executeQuery(Servlet.java
:140)
at anywheresoftware.b4a.remotedatabase.Servlet.doGet(Servlet.java:78)
at anywheresoftware.b4a.remotedatabase.Servlet.doPost(Servlet.java:52)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:538
)
at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java
:478)
at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandl
er.java:937)
at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:
406)
at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandle
r.java:871)
at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.j
ava:117)
at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper
.java:110)
at org.eclipse.jetty.server.Server.handle(Server.java:346)
at org.eclipse.jetty.server.HttpConnection.handleRequest(HttpConnection.
java:589)
at org.eclipse.jetty.server.HttpConnection$RequestHandler.content(HttpCo
nnection.java:1065)
at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:823)
at org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:220)

at org.eclipse.jetty.server.HttpConnection.handle(HttpConnection.java:41
1)
at org.eclipse.jetty.io.nio.SelectChannelEndPoint.handle(SelectChannelEn
dPoint.java:535)
at org.eclipse.jetty.io.nio.SelectChannelEndPoint$1.run(SelectChannelEnd
Point.java:40)
at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool
.java:529)
at java.lang.Thread.run(Unknown Source)
java.sql.SQLException: Function not implemented
at com.pervasive.jdbc.v2.PreparedStatement.getParameterMetaData(Prepared
Statement.java:653)
at com.mchange.v2.c3p0.impl.NewProxyPreparedStatement.getParameterMetaDa
ta(NewProxyPreparedStatement.java:303)
at anywheresoftware.b4a.remotedatabase.Servlet.createStatement(Servlet.j
ava:178)
at anywheresoftware.b4a.remotedatabase.Servlet.executeQuery(Servlet.java
:140)
at anywheresoftware.b4a.remotedatabase.Servlet.doGet(Servlet.java:78)
at anywheresoftware.b4a.remotedatabase.Servlet.doPost(Servlet.java:52)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:538
)
at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java
:478)
at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandl
er.java:937)
at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:
406)
at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandle
r.java:871)
at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.j
ava:117)
at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper
.java:110)
at org.eclipse.jetty.server.Server.handle(Server.java:346)
at org.eclipse.jetty.server.HttpConnection.handleRequest(HttpConnection.
java:589)
at org.eclipse.jetty.server.HttpConnection$RequestHandler.content(HttpCo
nnection.java:1065)
at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:823)
at org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:220)

at org.eclipse.jetty.server.HttpConnection.handle(HttpConnection.java:41
1)
at org.eclipse.jetty.io.nio.SelectChannelEndPoint.handle(SelectChannelEn
dPoint.java:535)
at org.eclipse.jetty.io.nio.SelectChannelEndPoint$1.run(SelectChannelEnd
Point.java:40)
at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool
.java:529)
at java.lang.Thread.run(Unknown Source)
 

opal

Member
Licensed User
Longtime User
Dear Erel, yes table animal missing, I sad that in post above. This message sent Pervasive SQL and because of that I know that java code called (comunicate with) Pervasive SQL, but table Person exist and server message is: java.sql.SQLException: Function not implemented. Log above include call of 3 different Sub, as I explained in post before. Execute first sub result: java.sql.SQLException: [LNA][Pervasive][ODBC Engine Interface][Data Record Manager]No such table or object. Execute second sub result: java.sql.SQLException: Function not implemented and same message I get when I execute last Sub.
 

alienhunter

Active Member
Licensed User
Longtime User

works perfect i enjoy this RDC more and more
thanks
 
Last edited:
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…