Problem in integrating Android application with Postgresql database

1,425 views
Skip to first unread message

ashish nayal

unread,
May 16, 2012, 2:50:02 AM5/16/12
to PgAndroid
I am developing a Android application with target Android 2.1.

In this application I try to integrate my application with Postgresql
database using jdbc driver.

But on running android emulator I am getting this error:

Caused by: java.lang.NoClassDefFoundError: org.postgresql.Driver

Dave Cramer

unread,
May 16, 2012, 6:00:43 AM5/16/12
to pgan...@googlegroups.com
Hi,

You need the postgresql driver jar in your classpath.

Dave Cramer

ashish nayal

unread,
May 16, 2012, 6:25:34 AM5/16/12
to PgAndroid
I have added postgresql jdbc driver in my android application using
following method:

MyAndroidProject->Properties->Java Build Path->Add External Jar

Then I have tried following jdbc drivers:

postgresql-9.0-801.jdbc4.jar
postgresql-9.0-801.jdbc3.jar
postgresql-8.3-606.jdbc4

But None of them work.

Also I have added in my application AndroidManifest.xml file following
line:

<uses-permission android:name="android.permission.INTERNET" />

But still it is not working.

Please let me know if I have to do any other setting to run this
application.

Dave Cramer

unread,
May 16, 2012, 8:17:07 AM5/16/12
to pgan...@googlegroups.com
Hi,

Well the error is saying it can't find it, and it is in the jar. I am
not familiar with android programming enough to be helpful at this
point.

Dave Cramer

ashish nayal

unread,
May 16, 2012, 8:36:04 AM5/16/12
to PgAndroid
Hi Dave,

I have also tried the the postgresql.jar you have developed but still
it is not working.
Please help me out.

Regards,
Ashish

On May 16, 5:17 pm, Dave Cramer <davecra...@gmail.com> wrote:
> Hi,
>

edir...@gmail.com

unread,
May 16, 2012, 8:37:01 AM5/16/12
to pgan...@googlegroups.com
Hi I've did it, and it works fine, let me arrive 2 my office, and I will help U. #LUV
Enviado desde mi oficina móvil BlackBerry® de Telcel

ashish nayal

unread,
May 16, 2012, 8:41:15 AM5/16/12
to PgAndroid
Hi edirav,

Please let me know the steps that i have to do to work this out.

Regards,
Ashish

paxau10

unread,
Nov 18, 2012, 12:09:46 PM11/18/12
to pgan...@googlegroups.com
Hi! today i was trying to do a simple connectios to my postgre database using android and i got the same problem. could you please telme me how did you solve the problem? best regards paxau

Michael Welter

unread,
Nov 18, 2012, 12:29:52 PM11/18/12
to pgan...@googlegroups.com

pg_hba.conf correct?

paxau10

unread,
Nov 18, 2012, 2:49:48 PM11/18/12
to pgan...@googlegroups.com
it has a default configuration! but this has any relatuinship with the driver?

Michael Welter

unread,
Nov 18, 2012, 2:53:08 PM11/18/12
to pgan...@googlegroups.com

pg_hba.conf must be configured to allow TCP communication with external devices.

paxau10

unread,
Nov 18, 2012, 2:53:36 PM11/18/12
to pgan...@googlegroups.com
could you plesse tel me the steps that i've to follow?


Domingo, 18 de Novembro de 2012 16:29:53 UTC-1, mike escreveu:

Michael Welter

unread,
Nov 18, 2012, 2:56:57 PM11/18/12
to pgan...@googlegroups.com

Read the pg_hba.conf file

paxau10

unread,
Nov 18, 2012, 3:10:08 PM11/18/12
to pgan...@googlegroups.com
 i add  the folowwing host    all             all             0.0.0.0/0            trust

and   this is my ph_hba.comf,
# TYPE  DATABASE        USER            ADDRESS                 METHOD

# IPv4 local connections:
host    all             all             127.0.0.1/32            md5
host    all             all             0.0.0.0/0            trust
# IPv6 local connections:
host    all             all             ::1/128                 md5
# Allow replication connections from localhost, by a user with the
# replication privilege.
#host    replication     postgres        127.0.0.1/32            md5
#host    replication     postgres        ::1/128                 md5


# TYPE  DATABASE        USER            ADDRESS                 METHOD

# IPv4 local connections:
host    all             all             127.0.0.1/32            md5
host    all             all             0.0.0.0/0            trust
# IPv6 local connections:
host    all             all             ::1/128                 md5
# Allow replication connections from localhost, by a user with the
# replication privilege.
#host    replication     postgres        127.0.0.1/32            md5
#host    replication     postgres        ::1/128                 md5

paxau10

unread,
Nov 18, 2012, 3:18:25 PM11/18/12
to pgan...@googlegroups.com
every time i try to connect to de database, i got  de classNotfoundExceptiom org.postgres.Driver.

if i create a java aplicatio , i can get data from my database. but in android app app a can not.




Domingo, 18 de Novembro de 2012 18:56:58 UTC-1, mike escreveu:

Dave Cramer

unread,
Nov 18, 2012, 5:33:16 PM11/18/12
to pgan...@googlegroups.com
Then you are not putting it in the classpath correctly.

Dave

Dave Cramer

paxau10

unread,
Nov 19, 2012, 6:11:16 AM11/19/12
to pgan...@googlegroups.com
hi! i can send
you my project,maybe there you can see what is wrong.

thanks in advance

Dave Cramer

unread,
Nov 19, 2012, 6:17:27 AM11/19/12
to pgan...@googlegroups.com
I haven't worked with android in quite a while, but sure, if I have time I'll look at it.

Dave

Dave Cramer

paxau10

unread,
Nov 19, 2012, 7:53:39 AM11/19/12
to pgan...@googlegroups.com

hei Dave, here is my project. it is a simple one , i´m just trying to connect to my postgre database  but  hwen i run as android app it thros a exception, classDriveNotFound.
my postgre version is 9.2 and the target API is 15(android 4.1)

best regards,  Isack
NhaDB.rar
Message has been deleted
Message has been deleted

Jasson Faerron Chavarria

unread,
Feb 8, 2013, 2:42:57 AM2/8/13
to pgan...@googlegroups.com
Help i have the same problem i can`t conect with postgresql :(............ i did every what do u said but still doesn`t work!!!!!!

Dave Cramer

unread,
Feb 8, 2013, 9:29:59 AM2/8/13
to pgan...@googlegroups.com
What exactly did you do. Adding the driver to the libraries should be all that is required

Dave Cramer


--
You received this message because you are subscribed to the Google Groups "PgAndroid" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pgandroid+...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Michael Welter

unread,
Feb 8, 2013, 9:35:34 AM2/8/13
to pgan...@googlegroups.com
You must first cause the PostgreSQL driver to be loaded.  Use the following statement:

Class.forName( "org.postgresql.Driver" );


--

Dave Cramer

unread,
Feb 8, 2013, 9:36:24 AM2/8/13
to pgan...@googlegroups.com
Sorry I presumed the OP was doing that at least.

Dave Cramer

Jasson Faerron Chavarria

unread,
Feb 8, 2013, 9:33:23 PM2/8/13
to pgan...@googlegroups.com
I got it jus check the JDBC  in “Properties > Java Build Path > Order and Export”, and check all the references you want exported" i dont know but is associated to ADT 17.... and i read it in this page http://android.foxykeep.com/dev/how-to-fix-the-classdefnotfounderror-with-adt-17

IT WORKS TY EVERYONE!!!!!

nihar srivastav

unread,
Jun 22, 2013, 1:37:17 PM6/22/13
to pgan...@googlegroups.com
Hi I am trying to connect a simple Android App to Postgresql database and its giving an error - java.sql.Sqlexception  No suitable driver .. .Can you please help out. We have tried everything and it looks like people have got this working. 

Your expertise will be highly appreciated

Thanks so much for the help 

David Caplin

unread,
Nov 10, 2014, 9:29:07 AM11/10/14
to pgan...@googlegroups.com
I had a similar issue, and spent weeks trying to solve it, assuming you still need an answer, run the whole Postgresql request under an AsyncTask instead of the main activity. Seemed to work for me. Hope this is useful for you if you still need it, or anyone else who stumbles upon it with the same error
-Skip
Reply all
Reply to author
Forward
0 new messages