Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1akrax-0003Vn-C2 for pgsql-jdbc@arkaria.postgresql.org; Tue, 29 Mar 2016 11:13:59 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1akraw-0002kM-VB for pgsql-jdbc@arkaria.postgresql.org; Tue, 29 Mar 2016 11:13:59 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1akraQ-00014G-R0 for pgsql-jdbc@postgresql.org; Tue, 29 Mar 2016 11:13:27 +0000 Received: from mail-wm0-x232.google.com ([2a00:1450:400c:c09::232]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.84_2) (envelope-from ) id 1akraM-00006P-Dg for pgsql-jdbc@postgresql.org; Tue, 29 Mar 2016 11:13:26 +0000 Received: by mail-wm0-x232.google.com with SMTP id p65so134118208wmp.1 for ; Tue, 29 Mar 2016 04:13:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=8kdata-com.20150623.gappssmtp.com; s=20150623; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to; bh=zRsCpOwhbJ+vqhF2RLdPdSk445RdoAK+VAiU2qon16k=; b=YpBF8ykxHB+ur93FiVvm8tCRMCU81wxjwnH4xrmnONiVFp3fl0Fc3qu6Z3sb9uMC4G 8yEbFaJGaUkhSljV3RjdHKZVqylgwHa6grbHEDnD5ltaucasoaiWPuO8P8pWTLCjt/Tq XZLf4WockRHCocs+uTd7SDVDFJD96b7LACpd3oHVzgyqcwxInCC0H8mkwq4TWh3420Rh ULKuX8zvEaQKrJO8DCDoCbk8OlS/zPOBFZZ/RxXFIydK0nEchqwadzTMiDzbQqx/t+qe X2F1QOlNZxM5NMMwsZPKaujrrGJ0V2J1BRYCjmwOALvXA8HU+hcHk6LhilMMHHihwZ6s zMcg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to; bh=zRsCpOwhbJ+vqhF2RLdPdSk445RdoAK+VAiU2qon16k=; b=HI6surNXPoRUSoULJqBrRCD8qzDLLGxeqnkc95sawcVBt7MF9Msr6lDPHIxTJUZEKs TXAB6Vfrz0YJVldktI63aaJ/viU/hCs3AHpuwKw3ekBANwq5Ruu6vbGS9YlSs37onaUF L7p9KLNCyRUa9PxI2BzbN2SJLLClhBrZnsSp84d+5ZDaxS5y259JqFidmzJdSYDIFNbw iLjhSDOHWp3TsMNBpM0mAAaM4T7lBYPWGEqouGwNoXnrf01zbKRN1mUJfAC3MWHihHp7 7y1M3Fzq4FSbg//8Tpq2Pklnlm7ui1adSKyQZwNizpa+K6gYMlQ9tosNCWrlnb8umDsM lLPg== X-Gm-Message-State: AD7BkJIX6s/iZ61UD23janGtDhS0/IDwAIO6QPuB56J/zdWjpHCzj3pUR9fs6a9d3cBvog== X-Received: by 10.194.205.103 with SMTP id lf7mr2014886wjc.147.1459250001150; Tue, 29 Mar 2016 04:13:21 -0700 (PDT) Received: from [192.168.1.50] (94.Red-79-154-22.dynamicIP.rima-tde.net. [79.154.22.94]) by smtp.gmail.com with ESMTPSA id e4sm14271137wma.10.2016.03.29.04.13.20 for (version=TLSv1/SSLv3 cipher=OTHER); Tue, 29 Mar 2016 04:13:20 -0700 (PDT) Subject: Re: Error:java.lang.ClassNotFoundException: org.postgresql.Driver To: pgsql-jdbc@postgresql.org References: From: =?UTF-8?Q?=c3=81lvaro_Hern=c3=a1ndez_Tortosa?= Message-ID: <56FA634F.1070209@8kdata.com> Date: Tue, 29 Mar 2016 13:13:19 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.6.0 MIME-Version: 1.0 In-Reply-To: Content-Type: multipart/alternative; boundary="------------050300070506090505010704" X-Pg-Spam-Score: -1.8 (-) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-jdbc Precedence: bulk Sender: pgsql-jdbc-owner@postgresql.org This is a multi-part message in MIME format. --------------050300070506090505010704 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit 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 > "; > > 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 | Email > |Map > * --------------050300070506090505010704 Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: 8bit
    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";

        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 | Email | Map

--------------050300070506090505010704--