It took me a while to figure out on how to connect from my Android cellphone to ActianZenDB. This time standard tutorial from Actian didn’t work at all. I even asked for help on Actian forum – but somehow advices given there didn’t work for me:
However after reading half of ActianZen Help, finally I found the solution, by accident;)
The solution is simple as a piece of cake…the answer is:
- usage of JDBC connector
- usage of standard Java libraries from ActianZen:
- jpscs.jar
- pvjdbc2.jar
- pvjdbc2x.jar
- database operations/connections should be opaqued in AsyncTask
- following permissions should be added to AndroidManifest.xml
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
and here is example on how this connection should look like in source code:
public class ThiefCatcher extends AppCompatActivity {
private static final String TAG = "ThiefCatcher";
private String mThief="";
private TextView mTextView;
private ImageView mImgView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.thiefcatcher);
new ConnectToDB().execute("");
}
private class ConnectToDB extends AsyncTask<String, Void, Long> {
protected Long doInBackground(String... strings) {
String lth,ldate;
long ret=1L;
try {
Class.forName("com.pervasive.jdbc.v2.Driver");
Log.i(TAG,"Driver loaded");
} catch (ClassNotFoundException e) {
e.printStackTrace();
}
Log.i(TAG,"before connection");
try {
Connection conn = DriverManager.getConnection("jdbc:pervasive://yourIP:odbc_port/maindb", "user", "passwd");
Log.i(TAG, "Connected:"+conn.toString());
try {
Statement stmt= conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,
ResultSet.CONCUR_UPDATABLE) ;
ResultSet rs = stmt.executeQuery("select top 1 image_name,timestamp from images");
Log.i(TAG,"selected from images!");
while (rs.next()) {
lth=rs.getString("image_name");
ldate=rs.getDate("timestamp").toString();
mThief=lth+";"+ldate;
Log.i(TAG,"returned from DB:"+mThief);
}
Log.i(TAG,"Closing result set");
rs.close();
stmt.close();
Log.i(TAG,"closing statement");
}catch (SQLException e)
{
ret=0L;
e.printStackTrace();
}finally {
conn.close();
Log.i(TAG,"closing connection");
}
}
catch (SQLException e) {
ret=0L;
e.printStackTrace();
}
return ret;
}
protected void onProgressUpdate(Integer... progress) {
}
protected void onPostExecute(Long result) {
if (result==1) {
Log.i(TAG, mThief);
mTextView = (TextView) findViewById(R.id.thiefTitle);
String[] str_arr = mThief.split(";");
if (str_arr.length > 1) {
str_arr[0] = str_arr[0].trim();
mTextView.setText("Thief caught at:"+str_arr[1]);
}
else
{
Toast.makeText(ThiefCatcher.this,"Cannot connecto to DB - check VLAN!",Toast.LENGTH_LONG).show();
}
}
}
}
After applying all of mentioned recipe and added some nice GUI, my application connects now to my Windows server as well as RaspberryPI robot and display last caught thief:

It’s really a cool and helpful piece of information. I am happy that you simply
shared this useful information with us. Please stay us up to
date like this. Thank you for sharing.
May I simplʏ јust say what a rеlief to find somebody that really understɑndѕ what they’re discusѕing over the іnternet.
You certainly realize how to bring a problem to light and make it іmⲣortant.
More people have to look at this and understand this siԀe ᧐f the storү.
I was surprised that you aren’t more populаr since you certaіnly havе the gift.