JDBC for Postgresql(on Linux): java.lang.NullPointerExceptio--Please HELP!

I'm trying to build a JSP web application with Apache Tomcat 4.0 on Linux, using PostgreSQL database.
The test page for building a connection to the database is very simple.
However, unfortunately, I always get the following error message from the web server.
The code is also show below.
I have another Tomcat server working on Window2000 with Oracle. So I change the JDBC driver to Oracle on that machine, and it works fine.
I guessed I might have some problem with the Tomcat setting, but I'm not sure what I need to change.
The directory of my web application is built under the webapps.
And I've added JAVA_HOME, JAVA_HOME/lib/tool.jar, and JDBC for PostgreSQL to my CLASSPATH.
Is there any other configuration that I missed?
Please help if you see the problem.
Thanks a lot in advance.
Error message:
type: Exception report
message: Internal Server Error
description: The server encountered an internal error (Internal Server Error) that prevented it from fulfilling this request.
exception
java.lang.NullPointerException
     at org.apache.jsp.index$jsp._jspService(index$jsp.java:231)
     at org.apache.jasper.runtime.HttpJspBase.service(Unknown Source)
     at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
     at org.apache.jasper.servlet.JspServlet$JspServletWrapper.service(Unknown Source)
     at org.apache.jasper.servlet.JspServlet.serviceJspFile(Unknown Source)
     at org.apache.jasper.servlet.JspServlet.service(Unknown Source)
     at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
     at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Unknown Source)
     at org.apache.catalina.core.ApplicationFilterChain.doFilter(Unknown Source)
     at org.apache.catalina.core.StandardWrapperValve.invoke(Unknown Source)
     at org.apache.catalina.core.StandardPipeline.invokeNext(Unknown Source)
     at org.apache.catalina.core.StandardPipeline.invoke(Unknown Source)
     at org.apache.catalina.core.ContainerBase.invoke(Unknown Source)
     at org.apache.catalina.core.StandardContextValve.invoke(Unknown Source)
     at org.apache.catalina.core.StandardPipeline.invokeNext(Unknown Source)
     at org.apache.catalina.core.StandardPipeline.invoke(Unknown Source)
     at org.apache.catalina.core.ContainerBase.invoke(Unknown Source)
     at org.apache.catalina.core.StandardContext.invoke(Unknown Source)
     at org.apache.catalina.core.StandardHostValve.invoke(Unknown Source)
     at org.apache.catalina.core.StandardPipeline.invokeNext(Unknown Source)
     at org.apache.catalina.valves.ErrorDispatcherValve.invoke(Unknown Source)
     at org.apache.catalina.core.StandardPipeline.invokeNext(Unknown Source)
     at org.apache.catalina.valves.ErrorReportValve.invoke(Unknown Source)
     at org.apache.catalina.core.StandardPipeline.invokeNext(Unknown Source)
     at org.apache.catalina.valves.AccessLogValve.invoke(Unknown Source)
     at org.apache.catalina.core.StandardPipeline.invokeNext(Unknown Source)
     at org.apache.catalina.core.StandardPipeline.invoke(Unknown Source)
     at org.apache.catalina.core.ContainerBase.invoke(Unknown Source)
     at org.apache.catalina.core.StandardEngineValve.invoke(Unknown Source)
     at org.apache.catalina.core.StandardPipeline.invokeNext(Unknown Source)
     at org.apache.catalina.core.StandardPipeline.invoke(Unknown Source)
     at org.apache.catalina.core.ContainerBase.invoke(Unknown Source)
     at org.apache.catalina.connector.http.HttpProcessor.process(Unknown Source)
     at org.apache.catalina.connector.http.HttpProcessor.run(Unknown Source)
     at java.lang.Thread.run(Thread.java:484)
Here's my code:
<%@ page language="java" import="java.io.*, java.sql.*, java.util.*, java.lang.*" %>
<HTML>
<HEAD>
<TITLE>TEST</TITLE>
</HEAD>
<BODY>
<b> City </b><br>
<%
     Class.forName("org.postgresql.Driver");
     String sqlurl = "jdbc:postgresql://localhost:5432/customer";
     String username = "guest";
     String passwd = username;
     Connection conn = DriverManager.getConnection(sqlurl, username, passwd);
     Statement st = conn.createStatement();
     String queryStr = "select CITY from WEATHER";
     ResultSet rs = st.executeQuery(queryStr);
     if (rs != null){
          while(rs.next()){
               String strCity = rs.getString(1);
%>
-- <%=strCity %> --<br>
<%
     st.close();
     conn.close();
%>
</BODY>
</HTML>

Error is not there in the code what you are showing. Can you edit index$jsp.java and see what is there in line 231?
You may find it in tomcat_home\work\your_application directory.
Sudha

Similar Messages

  • Exception in thread "main" java.lang.OutOfMemoryError(please help me )

    Hi All
    here my java class trying to read a txt file(which is having size of 60MB).and putting each line into a Vector class. problem is ,upto certain number of line it is reading properly and putting into vector..after that it is giving error like Exception in thread "main" java.lang.OutOfMemoryError..what is the problem and how to rectify this one..anybody help me on this.
    actual situation is one txt is there in that 80 lakhs of lines of content is there..java file trying to read each line and put it into vector or stringbuffer and split it into two lines like key=value and put it into hashmap object.then finally iam creating new file(.properties) and writing these hashmap data on it. if you want clearly..please look into below code..
    package test.utf8; import java.io.*; import java.util.*; public class AssetUtils
    //static StringBuffer stringbuffer = new StringBuffer();
    public AssetUtils()
    public static void main(String args[]) throws IOException
    BufferedReader bufferedreader = new BufferedReader(new InputStreamReader(new FileInputStream("D:\\list.txt")));
    Vector vector = new Vector(0x30D40, 50000);
    System.out.println(vector.capacity());
    Object obj = null;
    int n=0;
    System.out.println("Reading list:" + new Date(System.currentTimeMillis()));
    do
    String s = bufferedreader.readLine();
    //System.out.println("line no: "+ ++n);
    if(s == null)
    break;
    vector.add(s);
    } while(true);
    System.out.println("List Read complete:" + new Date(System.currentTimeMillis()));
    String s1 = args[0];
    System.out.println("S1: "+s1);
    System.out.println(vector.capacity());
    HashMap hashmap = new HashMap();
    System.out.println( "Vector.Size..>>>>>>>>>>>>>>>>.."+vector.size());
    for(int i = 0; i < vector.size(); i++)
    System.out.println("i value:"+i);
    String s2 = (String)vector.get(i);
    //System.out.println("S2: "+s2);
    if(s2.indexOf("/") != -1)
    String s3 = s2.substring(s1.length(), s2.length());
    //System.out.println("S3: "+s3);
    if(s3.indexOf("/") != -1) {
    String s4 = s3.substring(0, s3.lastIndexOf("/"));
    //System.out.println("S4: "+s4);
    String s6 = s3.substring(s3.lastIndexOf("/") + 1, s3.length());
    //System.out.println("S6: "+s6);
    StringBuffer stringbuffer=null;
    stringbuffer = new StringBuffer();
    String s8 = (String)hashmap.get(s4);
    //System.out.println("S8: "+s8);
    if(s8 != null) stringbuffer.append(s8 + "," + s6);
    else
    stringbuffer.append(s6);
    hashmap.put(s4, stringbuffer.toString());
    //stringbuffer.delete(0,stringbuffer.length());
    stringbuffer=null;
    System.out.println("Opening asset.properties:" + new Date(System.currentTimeMillis()));
    File file = new File("D:\\asset.properties");
    PrintWriter printwriter = new PrintWriter(new FileOutputStream(file));
    String s5;
    String s7;
    for(Iterator iterator = hashmap.keySet().iterator(); iterator.hasNext(); printwriter.println(s5 + "=" + s7))
    { s5 = (String)iterator.next(); s7 = (String)hashmap.get(s5); } printwriter.close();
    System.out.println("Closing asset.properties:" + new Date(System.currentTimeMillis()));

    Theres a number of ways you can improve your memory usage:
    1) Build you map as you read in your file.
    2) Use StringBuffers in your map - do not use "asshaj" + "ashaskj" This is very memory intensive
    If you still run out of memory try running the JVM using -Xms128m -Xmx512m or higher

  • Java.lang.NoSuchMethod: main - Help pls

    This is the code i got off a book but it seems like it's not working. I got an error which says 'java.lang.NoSuchMethod: main' Help pls...
    import java.io.*;
    import java.util.*;
    class PostfixInterpreter {
         private String postfixString, outputString;
    private boolean isOperator(char c) {
         return (c == '+' || c == '-' || c == '*' || c == '/' || c == '^' );
    private boolean isSpace(char c) {
         return (c == ' ');
    }//end isSpace
    public void interpretPostfix() {
         Stack evalStack= new Stack();
         double leftOperand, rightOperand;
         char c;
         StringTokenizer parser = new StringTokenizer(postfixString,"+-*/^ ", true);
         while (parser.hasMoreTokens()){
              String token = parser.nextToken();
              c = token.charAt(0);
              if ((token.length() == 1) && isOperator(c)) {
                   rightOperand = ((Double)evalStack.pop()).doubleValue();
                   leftOperand = ((Double)evalStack.pop()).doubleValue();
                   switch (c) {
                        case'+': evalStack.push(new Double(leftOperand+rightOperand));
                                       break;
                        case'-': evalStack.push(new Double(leftOperand-rightOperand));
                                       break;
                        case'*': evalStack.push(new Double(leftOperand*rightOperand));
                                       break;
                        case'/': evalStack.push(new Double(leftOperand/rightOperand));
                                       break;
                        case'^': evalStack.push(new Double(Math.exp(Math.log(leftOperand)*rightOperand)));
                                       break;
                        default:
                                       break;
                   }//end of switch
              }else if((token.length() == 1)&& isSpace(c)){
              }else {
                   evalStack.push(Double.valueOf(token));
              }//end if
         }//end while
    // remove final result from stack and output it
    output("value of postfix expression = " + evalStack.pop());
    }//end interpretPostfix
    private void output(String input){
         postfixString = input;
         }//end setInput
    public String getOutput(){
         return outputString;
    }//end getOutput
    }//end class PostfixInterpreter
    /*Stack class*/
    class Stack {
         private int count;
         private int capacity;
         private int capacityIncrement;
         private Object[] itemArray;
    //the following defines a no-arg constrcutor for Stack objects
    public Stack() {
         count = 0;
         capacity = 100;
         capacityIncrement = 5;
         itemArray = new Object[capacity];
         public boolean empty() {
              return (count ==0);
         public void push(Object X) {
              //if the itemArray does not have enough capacity
              //expend the itemArray by the capacity increment
                   if(count == capacity) {
                        capacity += capacityIncrement;
                        Object[] tempArray = new Object[capacity];
                        for (int i=0; i<count;i++){
                             tempArray[i] = itemArray;
                   itemArray=tempArray;
              //insert the new item X at the end of the current item sequence
              //and increase the stack's count by one
                   itemArray[count++]=X;
    public Object pop() {
         if(count==0){
              return null;
         }else{
              return itemArray[--count];
    }//end of pop()
    public Object peek() {
         if (count == 0){
              return null;
         }else{
              return itemArray[count-1];
    }//end peek()

    First, when posting code in the future, use the code /code tags. Just highlight the code and click the code. button.
    The error probably occurred when you tried to launch the class as an application by entering "java PostfixInterpreter" The java application launcher looks for a method in the PostfixInterpreter class whose signature is exactly public static void main(String[] args)(except 'args' can be any legal variable name). Since your PostfixInterpreter class doesn't have this method, you get the error. If you want this class to run, you have to include the method and code inside the method that runs the application.

  • Hello Sorry for the inconvenience, but I have a problem in Java I can not open files, audio chat, which type of jnlp after the last update of the Java 2012-004 Please help me in solving this problem.

    Hello Sorry for the inconvenience, but I have a problem in Java I can not open files, audio chat, which type of jnlp after the last update of the Java 2012-004
    Please help me in solving this problem. 

    Make sure Java is enable in your browser's security settings.
    Open Java Preferences (in Utilities folder)
    Make sure Web-start applications are enabled.
    Drag Java 32-bit to the top of the list.
    jnlp isn't an audio file format. It's just a java web-start program (Java Network Launching Protocol).

  • Java.lang.Error: IP Helper Library GetIfTable function failed

    Some of our users are sometimes getting the following exception:
    java.lang.Error: IP Helper Library GetIfTable function failed
    java.net.NetworkInterface.getAll(Native Method)
    java.net.NetworkInterface.getNetworkInterfaces(Unknown Source)
    Does anyone know why this happens and what can be done against it?
    Is this a bug?

    The operating system is     Windows XP, Java is version 1.6.0_03 Sun Microsystems Inc.
    Today, I got another error report containing this error. They all seem to come from the same user. Given that the user is still using our product, I guess it doesn't happen every time. :) The error actually happens in a third party library that uses JNI, so it could also be possible that this library messes up something. Given that the error happens rather rarely and we haven't got much data, I guess it isn't worth investigating this further at the moment.

  • How to attach a word file in JAVA mail? Please help

    I am a JAVA rookie and I have problem attaching a word file using javamail. I searched almost all the forum but still couldn't find the solution.
    Sorry for the reposting. But can anybody please help me out? Your any words or links will be highly appreciated!
    Lakobe

    If you want to include an attachment with your message, you need to build up the parts, quite literally, because the name of the applicable interface is Part. The content of your Message will consist of multiple parts within a Multipart object. Part one of the message is a BodyPart that contains the message content. Part two of the message is a BodyPart that contains the attachment. The attachment itself is specified as a DataSource. You don't have to actually read the attachment.
    You start in the same way as you do for a message without an attachment. Create the message from the session and initialize the headers:
    Message message = new MimeMessage(session);
    message.setFrom(new InternetAddress(from));
    message.addRecipient(Message.RecipientType.TO,
    new InternetAddress(to));
    message.setSubject("JDC Attachment");
    However here you need to create the Multipart object:
    Multipart multipart = new MimeMultipart();
    For part one, create a BodyPart and set the text to be a message. Then, add the BodyPart to the Multipart you just created.
    BodyPart messageBodyPart = new MimeBodyPart();
    messageBodyPart.setText("Here's the file");
    multipart.addBodyPart(messageBodyPart);
    For part two, you need to create a BodyPart again, but this time you need to create a DataSource for the file.
    messageBodyPart = new MimeBodyPart();
    DataSource source = new FileDataSource(filename);
    Use a DataHandler object to attach the data source to the message. Simply create a DataHandler for the source and attach it to the message:
    messageBodyPart.setDataHandler(
    new DataHandler(source));
    Remember to set the filename of the attachment. This permits the recipient to know the name (and type) of the received file.
    messageBodyPart.setFileName(filename);
    Attach part two in the same way as part one:
    multipart.addBodyPart(messageBodyPart);
    And as a final step before sending, attach the Multipart to the Message:
    message.setContent(multipart);

  • I own a MacBook Pro 2.4 ghz non unibody. I turn on my laptop for ten seconds and it freezes. It boots perfectly and runs for ten seconds until everything freezes. Please help!

    I own a MacBook Pro 2.4 ghz non unibody. I turn on my laptop for ten seconds and it freezes. It boots perfectly and runs for ten seconds until everything freezes. Please help!

    See if you can boot into single user mode with Command S.

  • HT201412 My cousin bought iPod touch 5th gen. Then it doesn't turned on. He charge it a charge icon appeared but after 30 mins still off . Is that normal for a brand new iPod touch? Please help me..

    My cousin bought iPod touch 5th gen. Then it doesn't turned on. He charge it a charge icon appeared but after 30 mins still off . Is that normal for a brand new iPod touch? Please help me..

    Not Charge
    - See:    
    iPod touch: Hardware troubleshooting
    iPhone and iPod touch: Charging the battery
    - Try another cable. The cable for 5G iPod (lightning connector) seems to be more prone to failure than the older cable.
    - If a 5G iPod      
    Iphone 5 lightning port charging problem - SOLUTION!
    - Try another charging source
    - Inspect the dock connector on the iPod for bent or missing contacts, foreign material, corroded contacts, broken, missing or cracked plastic.
    - Make an appointment at the Genius Bar of an Apple store.
      Apple Retail Store - Genius Bar
    and
    try:                                               
    - iOS: Not responding or does not turn on           
    - Also try DFU mode after try recovery mode
    How to put iPod touch / iPhone into DFU mode « Karthik's scribblings
    - If not successful and you can't fully turn the iOS device fully off, let the battery fully drain. After charging for an least an hour try the above again.
    - Try another cable       
    - Try on another computer                                                       
    - If still not successful that usually indicates a hardware problem and an appointment at the Genius Bar of an Apple store is in order.
      Apple Retail Store - Genius Bar                              

  • My iPhone 4 keeps asking me to enter the apple ID for an account which no longer exists-.please help

    my iPhone 4 keeps asking me to enter the apple ID for an account which no longer exists….please help

    I should have also said that the only reason this is causing me an issue is because I have bought a new phone and I want to sell this one.  But I cannot erase all data because I cannot turn off find my phone because it keeps asking for the password for an account which no longer exists…. have tried so many suggestions but nothing is working...

  • I am using a friend's iPod, whose account i signed out of, and signed in through my own. But whenever I'm trying to download an update or an app, it's still asking for the other account's password. Please help!!

    I am using a friend's iPod, whose account i signed out of, and signed in through my own. But whenever I'm trying to download an update or an app, it's still asking for the other account's password. Please help!!

    That Apple ID is stored inside those applications. Leave them as is and ask your friend to do the updating.
    (106675)

  • How do i set a default time of 2.0 seconds for all transitions in iMovie 10.  Please help.,

    how do i set a default time of 2.0 seconds for all transitions in iMovie 10.  Please help.,

    Start Firefox in <u>[[Safe Mode|Safe Mode]]</u> to check if one of the extensions or if hardware acceleration is causing the problem (switch to the DEFAULT theme: Firefox/Tools > Add-ons > Appearance/Themes).
    *Don't make any changes on the Safe mode start window.
    *https://support.mozilla.org/kb/Safe+Mode
    If you do not keep changes after a restart then see:
    *http://kb.mozillazine.org/Preferences_not_saved
    *https://support.mozilla.org/kb/Preferences+are+not+saved

  • What is the reason for these messages appearing in the report Please help

    Hi Guru's,
    In BI Report Output displays following warning message along with Report Output
    Warning Messages : (
    Characteristic Organizational Unit has no master data for "00000000" or you do not have authorization
    An invalid selection for characteristic Organizational Unit has been discarded )
    Please help me by providing the inputs what might be causing this issue.
    So that I can resolve this.
    Organizational Unit(0EMPLOYEE_0ORGUNIT) is present in selection screen of report.
    Orgaizational unit(0EMPLOYEE_0ORGUNIT) is the attribute of Employee.
    First when I got this warning messages I found that master data for 0employee was loaded but not for loaded for 0orgunit
    So I loaded the data for 0orgunit (attr, text and hierarchy) and Then again loaded for 0Employee
    Then I run attribute change run for 0EMPLOYEE and 0ORGUNIT
    I thought this would resolve the issue
    After doing the above steps also I am still getting same warning message
    Please gurus help
    Thanks,
    Deepika

    Hi Depika,
    Refer the SAP Note 1149556 - Characteristic ... has no master data for "..."
    Hope this helps.
    Regards,
    Hari.

  • I paid for membership and cannot access the program please help???????

    I paid for the program and cannot access it please help may i talk to someone?

    Did you install the trial or any update version?
    What were the instructions when you purchased?

  • My isight camera was not working. so i tried to smc reset it as said in apples support community but now wat happened is my macbook pro don't charge, it don't show any light for checking charge, nor it starts up. please help. Thanks

    my isight camera was not working. so i tried to smc reset it as said in apples support community but now wat happened is my macbook pro don't charge, it don't show any light for checking charge, nor it starts up. please help. Thanks

    Try zapping the PRAM.  See KB Article http://support.apple.com/kb/PH11243 OS X Mountain Lion: Reset your computer’s PRAM
    If you are still under warranty and/or have AppleCare, call them.  Let them deal w/it.

  • I have a really really big problem to my iphone icloud please help me i could send you my birth certificate for confirmation that im the real user please help me

         i have a really really big problem to my iphone icloud please help me i could send you my birth certificate for confirmation that im the real user please help me apple.corp and please tell me if this is not possible to be done it almost a month that i cant use my iphone.
         thank you for those who read this
    <Email Edited by Host>

    Remove your email address.  This is a public website, and you are addressing thousands of strangers.
    After doing that, tell us what your issue actually is.  This is a user-to-user technical forum.  You are not addressing Apple here.

Maybe you are looking for

  • Stored Procedure Command issues in CS3

    I've been having a problem using some stored procedures in CS3 which had previously worked with no issue in 8.0.2. I'm running CS3 on a Mac for ASP & SQL Server 2000. The input parameters for the stored procedure are... Fieldname: CategoryID (int) le

  • Service Bus(OSB) not harvesting Endpoint to Enterprise Repository(OER)

    Hi, I am harvesting a WSDL-based HTTP Proxy Service from Oracle Service Bus (OSB) to Oracle Enterprise Repository (OER) but the Endpoint is not harvested. The other artifacts are harvested successfully. Can someone please help Thanks, Umar

  • Collect response PDF forms and use responses in XLS

    Hello, If I have a PDF forms, and I collect forms complete, can I transform received replies in excel format, without publish data's in internet? Thanks

  • Un-link list of preferred WiFi networks between devices

    I have one wifi network for internet access, and another one for TimeCapsule. TimeCapsule is for my MacBook. But I DON'T WANT MY iPad TO JOIN THE TimeCapsule network. The issue is: when I tell my iPad to "Forget this network", it also dissappears fro

  • Need a query to find newline characters data( either chr(10) or chr(13))

    I have 5 columns in a table and these columns have newline characters data( either chr(10) or chr(13)). Now I need to fetch data so that all the records which have new line character( either chr(10) or chr(13) ) in any of these 5 columns should be re