pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Error:java.lang.ClassNotFoundException: org.postgresql.Driver
6+ messages / 5 participants
[nested] [flat]

* Error:java.lang.ClassNotFoundException: org.postgresql.Driver
@ 2016-03-29 11:04 Nithin Chakravarthi <nithin@embdestech.co.in>
  2016-03-29 11:13 ` Re: Error:java.lang.ClassNotFoundException: org.postgresql.Driver Álvaro Hernández Tortosa <aht@8kdata.com>
  2016-03-29 16:38 ` Re: Error:java.lang.ClassNotFoundException: org.postgresql.Driver danap <danap@itstriangle.com>
  2016-03-29 19:16 ` Re: Error:java.lang.ClassNotFoundException: org.postgresql.Driver M. Dietrich <mdt@emdete.de>
  0 siblings, 3 replies; 6+ messages in thread

From: Nithin Chakravarthi @ 2016-03-29 11:04 UTC (permalink / raw)
  To: pgsql-jdbc

Hi All,

I am working on java project to insert and fetch data from postgresql
database. While using jbdc I am getting error

"










*java.lang.ClassNotFoundException: org.postgresql.Driver    at
java.net.URLClassLoader.findClass(URLClassLoader.java:381)    at
java.lang.ClassLoader.loadClass(ClassLoader.java:424)    at
sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)    at
java.lang.ClassLoader.loadClass(ClassLoader.java:357)    at
java.lang.Class.forName0(Native Method)    at
java.lang.Class.forName(Class.java:264)    at
SqlConnection.sql_connection(SqlConnection.java:29)    at
ServerConnection.run(ServerConnection.java:205)    at
java.lang.Thread.run(Thread.java:745)"*
FYI I am using multiple source files. Main function is defined in one file
and I am using postgresql connection in another file

Here is my src
























*"private static final String DB_URL =
"jdbc:postgresql://127.0.0.1:5432/testdb
<http://127.0.0.1:5432/testdb>";;        public int sql_connection(String
outletid, String messageid, String checkid,int msgarry,String
message,PrintStream os)        {                        String []lines =
message.split("\\?");                        String [] separated =
lines[0].split("\\|");                                //for(int
i=0;i<4;i++)
//System.out.println("received  msg from client
:"+separated[i]);                        msgformation pack = new
msgformation();                        System.out.println("sizes---: "
+separated.length+" ---Arry Received: "+ msgarry);
if(separated.length==msgarry){
try{                                        System.out.println("Connecting
to database...");                                        Properties
password = new Properties();
password.put("user","postgress");
password.put("password","postgress");
password.put("host","localhost");
Class.forName("org.postgresql.Driver");
//DriverManager.register(org.postgresql.Driver());
ServerMain.conn = DriverManager.getConnection(DB_URL,password);"*
I have exported class path as


*"export CLASSPATH=./Server.jar:~/Downloads/postgresql-9.3-1103.jdbc3.jar"*

Server.jar is main executable file.

So please help me to solve this issue.
Thanks & Regards,
*M. Nithin Chakravrthi*
Software Engineer

*EmbDes Technologies Pvt Ltd*
#124,2nd Floor,Hosur Main Road, Madiwala,| Bangalore-68 | Karnataka, India
Tel: 080-25537562 | Mob: +91-8050597236

*Website <http://www.embdestech.co.in/; | Email
<nithin@embdestech.co.in> | Map
<https://www.google.com/maps/place/EmbDes+Technologies/@12.9198502,77.6193159,17z/data=!3m1!4b1!4m2!3...

^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* Re: Error:java.lang.ClassNotFoundException: org.postgresql.Driver
  2016-03-29 11:04 Error:java.lang.ClassNotFoundException: org.postgresql.Driver Nithin Chakravarthi <nithin@embdestech.co.in>
@ 2016-03-29 11:13 ` Álvaro Hernández Tortosa <aht@8kdata.com>
  2 siblings, 0 replies; 6+ messages in thread

From: Álvaro Hernández Tortosa @ 2016-03-29 11:13 UTC (permalink / raw)
  To: pgsql-jdbc


     IMVHO, I completely got rid of issues like this when I started 
using Maven (or Gradle or equivalent).

     I'd recommend you to do the same (and by the way, use a more modern 
version of the driver).


     Álvaro


-- 
Álvaro Hernández Tortosa


-----------
8Kdata




On 29/03/16 13:04, Nithin Chakravarthi wrote:
> Hi All,
>
> I am working on java project to insert and fetch data from postgresql 
> database. While using jbdc I am getting error
>
> "*java.lang.ClassNotFoundException: org.postgresql.Driver
>     at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
>     at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
>     at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
>     at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
>     at java.lang.Class.forName0(Native Method)
>     at java.lang.Class.forName(Class.java:264)
>     at SqlConnection.sql_connection(SqlConnection.java:29)
>     at ServerConnection.run(ServerConnection.java:205)
>     at java.lang.Thread.run(Thread.java:745)
> "
> *
> FYI I am using multiple source files. Main function is defined in one 
> file and I am using postgresql connection in another file
>
> Here is my src
>
> *"private static final String DB_URL =
>                           "jdbc:postgresql://127.0.0.1:5432/testdb 
> <http://127.0.0.1:5432/testdb>";;
>
>         public int sql_connection(String outletid, String messageid, 
> String checkid,int msgarry,String message,PrintStream os)
>         {
>                         String []lines = message.split("\\?");
>                         String [] separated = lines[0].split("\\|");
>                                 //for(int i=0;i<4;i++)
> //System.out.println("received  msg from client :"+separated[i]);
>                         msgformation pack = new msgformation();
>                         System.out.println("sizes---: " 
> +separated.length+" ---Arry Received: "+ msgarry);
>                         if(separated.length==msgarry){
>                                 try{
> System.out.println("Connecting to database...");
>                                         Properties password = new 
> Properties();
> password.put("user","postgress");
> password.put("password","postgress");
> password.put("host","localhost");
> Class.forName("org.postgresql.Driver");
> //DriverManager.register(org.postgresql.Driver());
>                                         ServerMain.conn = 
> DriverManager.getConnection(DB_URL,password);
>
> "
> *
> I have exported class path as
>
> *"export CLASSPATH=./Server.jar:~/Downloads/postgresql-9.3-1103.jdbc3.jar"
> *
>
> Server.jar is main executable file.
>
> So please help me to solve this issue.
> Thanks & Regards,
> *M. Nithin Chakravrthi*
> Software Engineer
>
> *EmbDes Technologies Pvt Ltd*
> #124,2nd Floor,Hosur Main Road, Madiwala,| Bangalore-68 |Karnataka,**India
> Tel: 080-25537562 | Mob: +91-8050597236
>
> *Website <http://www.embdestech.co.in/; | Email 
> <mailto:nithin@embdestech.co.in> |Map 
> <https://www.google.com/maps/place/EmbDes+Technologies/@12.9198502,77.6193159,17z/data=%213m1%214b1%2...

^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* Re: Error:java.lang.ClassNotFoundException: org.postgresql.Driver
  2016-03-29 11:04 Error:java.lang.ClassNotFoundException: org.postgresql.Driver Nithin Chakravarthi <nithin@embdestech.co.in>
@ 2016-03-29 16:38 ` danap <danap@itstriangle.com>
  2 siblings, 0 replies; 6+ messages in thread

From: danap @ 2016-03-29 16:38 UTC (permalink / raw)
  To: Nithin Chakravarthi <nithin@embdestech.co.in>; pgsql-jdbc

Nithin Chakravarthi wrote:
> Hi All,
>
> I am working on java project to insert and fetch data from postgresql database.
> While using jbdc I am getting error
>
> "*java.lang.ClassNotFoundException: org.postgresql.Driver
>      at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
>
> ~
 > ~
 > ~
>
> //DriverManager.register(org.postgresql.Driver());
>                                          ServerMain.conn =
> DriverManager.getConnection(DB_URL,password);
>
> "
> *
> I have exported class path as
>
> *"export CLASSPATH=./Server.jar:~/Downloads/postgresql-9.3-1103.jdbc3.jar"
> *
>
> Server.jar is main executable file.
>
> So please help me to solve this issue.
> //
> Thanks & Regards,
> *M. Nithin Chakravrthi*
> Software Engineer

Hello Nithin,

Yes you can use Maven or other to build your jar or can
use the basics which is valuable in understanding the
process by compiling directly, and creating the jar
with the commands, javac, jar. Insure these are on your
execution path.

See Example Files:

   https://github.com/danap/myjsqlview

   make, build, myjsqlview.mf

   make - Compiles your source files to the specified directly.
          Use the -classpath to defines libraries, jars, required
          in the compile.

   build - Creates your jar file with included jars, your case
           and other files.

   myjsqlview.mf - specifiy the inclusion here the main class and
                   required jar, postgresql driver here.

Use the .bat files for Win, .sh for Unix/Linux.

Alternative, just place the postgresql driver in the jre/lib/ext
folder.

danap.






-- 
Sent via pgsql-jdbc mailing list (pgsql-jdbc@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-jdbc



^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* Re: Error:java.lang.ClassNotFoundException: org.postgresql.Driver
  2016-03-29 11:04 Error:java.lang.ClassNotFoundException: org.postgresql.Driver Nithin Chakravarthi <nithin@embdestech.co.in>
@ 2016-03-29 19:16 ` M. Dietrich <mdt@emdete.de>
  2016-03-29 19:34   ` Re: Error:java.lang.ClassNotFoundException: org.postgresql.Driver John R Pierce <pierce@hogranch.com>
  2 siblings, 1 reply; 6+ messages in thread

From: M. Dietrich @ 2016-03-29 19:16 UTC (permalink / raw)
  To: Nithin Chakravarthi <nithin@embdestech.co.in>; pgsql-jdbc

Zitat aus Nithin Chakravarthi's Nachricht :
> *"export CLASSPATH=./Server.jar:~/Downloads/postgresql-9.3-1103.jdbc3.jar"*

java does not expand the "~" denoting your home dir, use `pwd`
instead to let the shell do that or name the full filename
with absolute directory.



-- 
Sent via pgsql-jdbc mailing list (pgsql-jdbc@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-jdbc



^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* Re: Error:java.lang.ClassNotFoundException: org.postgresql.Driver
  2016-03-29 11:04 Error:java.lang.ClassNotFoundException: org.postgresql.Driver Nithin Chakravarthi <nithin@embdestech.co.in>
  2016-03-29 19:16 ` Re: Error:java.lang.ClassNotFoundException: org.postgresql.Driver M. Dietrich <mdt@emdete.de>
@ 2016-03-29 19:34   ` John R Pierce <pierce@hogranch.com>
  2016-03-30 21:20     ` Re: Error:java.lang.ClassNotFoundException: org.postgresql.Driver M. Dietrich <mdt@emdete.de>
  0 siblings, 1 reply; 6+ messages in thread

From: John R Pierce @ 2016-03-29 19:34 UTC (permalink / raw)
  To: pgsql-jdbc

On 3/29/2016 12:16 PM, M. Dietrich wrote:
> Zitat aus Nithin Chakravarthi's Nachricht :
>> *"export 
>> CLASSPATH=./Server.jar:~/Downloads/postgresql-9.3-1103.jdbc3.jar"*
>
> java does not expand the "~" denoting your home dir, use `pwd`
> instead to let the shell do that or name the full filename
> with absolute directory.

I'd suggest:

     export 
CLASSPATH=./Server.jar:$HOME/Downloads/postgresql-9.3-1103.jdbc3.jar

that $HOME will get expanded when the 'set' is being done, so the value 
of $CLASSPATH will contain ...:/home/whatever/Downloads/...




-- 
john r pierce, recycling bits in santa cruz



-- 
Sent via pgsql-jdbc mailing list (pgsql-jdbc@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-jdbc



^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* Re: Error:java.lang.ClassNotFoundException: org.postgresql.Driver
  2016-03-29 11:04 Error:java.lang.ClassNotFoundException: org.postgresql.Driver Nithin Chakravarthi <nithin@embdestech.co.in>
  2016-03-29 19:16 ` Re: Error:java.lang.ClassNotFoundException: org.postgresql.Driver M. Dietrich <mdt@emdete.de>
  2016-03-29 19:34   ` Re: Error:java.lang.ClassNotFoundException: org.postgresql.Driver John R Pierce <pierce@hogranch.com>
@ 2016-03-30 21:20     ` M. Dietrich <mdt@emdete.de>
  0 siblings, 0 replies; 6+ messages in thread

From: M. Dietrich @ 2016-03-30 21:20 UTC (permalink / raw)
  To: John R Pierce <pierce@hogranch.com>; pgsql-jdbc

Zitat aus John R Pierce's Nachricht :
> On 3/29/2016 12:16 PM, M. Dietrich wrote:
>> Zitat aus Nithin Chakravarthi's Nachricht :
>>> *"export 
>>> CLASSPATH=./Server.jar:~/Downloads/postgresql-9.3-1103.jdbc3.jar"*
>> java does not expand the "~" denoting your home dir, use `pwd`
>> instead to let the shell do that or name the full filename
>> with absolute directory.
> I'd suggest:
> 
>      export CLASSPATH=./Server.jar:$HOME/Downloads/postgresql-9.3-1103.jdbc3.jar
> 
> that $HOME will get expanded when the 'set' is being done, so the value 
> of $CLASSPATH will contain ...:/home/whatever/Downloads/...

correct, pwd does not do the job, sorry ;)


-- 
Sent via pgsql-jdbc mailing list (pgsql-jdbc@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-jdbc



^ permalink  raw  reply  [nested|flat] 6+ messages in thread


end of thread, other threads:[~2016-03-30 21:20 UTC | newest]

Thread overview: 6+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2016-03-29 11:04 Error:java.lang.ClassNotFoundException: org.postgresql.Driver Nithin Chakravarthi <nithin@embdestech.co.in>
2016-03-29 11:13 ` Álvaro Hernández Tortosa <aht@8kdata.com>
2016-03-29 16:38 ` danap <danap@itstriangle.com>
2016-03-29 19:16 ` M. Dietrich <mdt@emdete.de>
2016-03-29 19:34   ` John R Pierce <pierce@hogranch.com>
2016-03-30 21:20     ` M. Dietrich <mdt@emdete.de>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox