Jsp database access using odbc - please help

Hi friends,
I�m trying a very simple database access program in jsp data base access using odbc. Odbc has to be used because thin driver or other drivers may not be available in every system of our college and as you know it's not that easy to make changes to those systems. My problem is so simple. I always get an exception in my program.
My jsp content is as simple as:
<%@ page import="java.lang.*,java.sql.*,java.io.*,registerbean" %>
<jsp:useBean id="db" class="registerbean" scope="session"/>
<%
String str="insert into reg values('" + db.getName() + "','" + db.getUname() + "','" + db.getPass() + "'," + db.getAge() + ",'" + db.getSex() + "','" + db.getAdd() + "','" + db.getUgcourse() + "','" + db.getUgqual() + "'," + db.getPer() + ",'" + db.getIadd() + "')";
try
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con=DriverManager.getConnection("jdbc:odbc:yogaesh","scott","tiger");
Statement stmt=con.createStatement();
stmt.executeUpdate(str);
}catch(Exception e1){out.println(str);};
%>
the table reg has the structure:
Name Null? Type
CNAME VARCHAR2(20)
UNAME VARCHAR2(20)
CPSWD VARCHAR2(20)
CONFPASS VARCHAR2(20)
CAGE NUMBER
CSEX VARCHAR2(5)
CADD VARCHAR2(100)
COURSE NUMBER
CQUAL VARCHAR2(10)
CPER NUMBER
IADD VARCHAR2(100)
The registerbean.java file is as below: (This seems to work fine because I tried printing the values using <%= %> tag and it worked out fine and moreover the query string is intact.)
import java.io.*;
import java.util.*;
import java.lang.*;
public class registerbean
private String name,uname,pass,cpass,age,sex,add,ugcourse,ugqual,per,iadd,otherugqual,ccode;
public void setName(String a)
name=a;
public void setUname(String a)
uname=a;
public void setPass(String a)
pass=a;
public void setCpass(String a)
cpass=a;
public void setAge(String a)
age=a;
public void setSex(String a)
sex=a;
public void setAdd(String a)
add=a;
public void setOtherugqual(String a)
otherugqual=a;
public void setCcode(String a)
ccode=a;
public void setUgcourse(String a)
ugcourse=a;
public void setUgqual(String a)
ugqual=a;
public void setPer(String a)
per=a;
public void setIadd(String a)
iadd=a;
public String getName()
return(name);
public String getUname()
return(uname);
public String getPass()
return(pass);
public String getCpass()
return(cpass);
public String getAge()
return(age);
public String getCcode()
return(ccode);
public String getSex()
return(sex);
public String getAdd()
return(add);
public String getUgcourse()
return(ugcourse);
public String getUgqual()
return(ugqual);
public String getPer()
return(per);
public String getIadd()
return(iadd);
public String getOtherugqual()
return(otherugqual);
I initially thought the problem was with str but then str seems to be perfect and I get a string of the form �insert into reg values('c','c','c',98,'Male','c','B.Tech, Applied Artificial Neural Networks','HSC',9898,'h')� which I verified through a javascript debugger. The session scope used is to get values through the db bean from another jsp file. The problem is in the executeUpdate() line of this code. I even tried changing the updation table, but in vain. What could be done to rectify this? Please help me out and please do remember that I have no option but to use odbc.
Thanks in advance.
R. Yogaesh.

I didn't verify the type of exception and i'm now going to do that, but then when the string is as perfect as needed, what is the need for a prepared statement? What is the basic difference between the two? And basically what is the problem with this piece of code which creates an exception? Please reply as soon as possible.
Thankyou very much.
R. Yogaesh.

Similar Messages

  • How can i access to iCloud to my iphone because it appear to the screen of my iPhone when i try to access my iCloud that the maximum number of free account have been use already please help me

    how can i access to iCloud to my iphone because it appear to the screen of my iPhone when i try to access my iCloud that the maximum number of free account have been use already please help me

    Welcome to the Apple community.
    Once three iCloud accounts have been created on any iOS device, it can you no longer be used to create any more accounts, regardless of what you do to it. You will need to use a computer or another iOS device to create your account and then use the details to log into your account on your phone.

  • I have business catalyst website imported in Dreamweaver. But I am unable to find or use database for it. Please help me into this

    I have business catalyst website imported in Dreamweaver. But I am unable to find or use database for it. Please help me into this

    You might find better help here: Dreamweaver & Business Catalyst
    Additional Info: Dreamweaver Help | Dreamweaver-Business Catalyst integration

  • JSP Database access - Urgent

    Hi,
    A simple data access program to set values in a db. I have the following problems.
    1. When I dont use if(request.getParameter("name")!=null) or any other parameter for testing null values, a row of null values is inserted each time I enter the jsp file.
    2. One more problem is that the update is not regular. It sometimes works fine, someother times it fails miserably. It seems that the connection is not closed properly as I receive such a message when I try to shut dwon oracle.
    3. A much more peculiar problem, when i paste a url directly into my browser, it runs fine, but not with location.href or a flash link!! eg the register.jsp file is reported as a nonexisting file (HTTP 404) when I provide a link to it from flash in the form http://localhost:8080/reg/register.jsp but when i type this url directly it works fine.
    My code for register.jsp is:
    <%@ page import="java.io.*,java.lang.*,java.sql.*,java.util.*"%>
    <%
    try {
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    Connection con=DriverManager.getConnection("jdbc:odbc:yogaesh","scott","tiger");
    Statement stmt=con.createStatement();
    if(request.getParameter("name")!=null)
    String str="insert into rt values('" + request.getParameter("name") + "','" + request.getParameter("uname") + "','" + request.getParameter("pass") + "','" + request.getParameter("cpass") + "'," + request.getParameter("age") + ",'" + request.getParameter("sex") + "','" + request.getParameter("add") + "'," + request.getParameter("code") + ",'" + request.getParameter("ugqual") + "'," + request.getParameter("per") + ",'" + request.getParameter("iadd") +"')";
    stmt.executeUpdate(str);
    stmt.close();
    con.commit();
    con.close();
    con=null;
    str=null;
    }catch(Exception e){out.println("Database error!!");}
    %>
    Please help me out and thanks in advance...
    R. Yogaesh.

    Hi,
    A simple data access program to set values in a db. I
    have the following problems.
    1. When I dont use
    if(request.getParameter("name")!=null) or any other
    parameter for testing null values, a row of null
    values is inserted each time I enter the jsp file. *********
    * Yup. Use .equals("") or .equals("null") as tests, depends on your servlet container
    2. One more problem is that the update is not regular.
    It sometimes works fine, someother times it fails
    miserably. It seems that the connection is not closed
    properly as I receive such a message when I try to
    shut dwon oracle. *************************
    Use this:
    Connection conn = null;
    try{
       //Do database stuff
    } catch {
       // Report your errors
    } finally{
       try{
         if(conn!= null){
            conn.close();
         }catch{}
    3. A much more peculiar problem, when i paste a url
    directly into my browser, it runs fine, but not with
    location.href or a flash link!! eg the register.jsp
    file is reported as a nonexisting file (HTTP 404) when
    I provide a link to it from flash in the form
    http://localhost:8080/reg/register.jsp but when i type
    this url directly it works fine.***********************
    Maybe your flash is on another computer/server? Try using the link http://<ip address>:8080/reg/register.jsp or http://<dns name>:8080/reg/register.jsp
    My code for register.jsp is:
    <%@ page
    import="java.io.*,java.lang.*,java.sql.*,java.util.*"%>
    <%
    try {
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    Connection
    con=DriverManager.getConnection("jdbc:odbc:yogaesh","sc
    tt","tiger");
    Statement stmt=con.createStatement();
    if(request.getParameter("name")!=null)
    String str="insert into rt values('" +
    request.getParameter("name") + "','" +
    request.getParameter("uname") + "','" +
    request.getParameter("pass") + "','" +
    request.getParameter("cpass") + "'," +
    request.getParameter("age") + ",'" +
    request.getParameter("sex") + "','" +
    request.getParameter("add") + "'," +
    request.getParameter("code") + ",'" +
    request.getParameter("ugqual") + "'," +
    request.getParameter("per") + ",'" +
    request.getParameter("iadd") +"')";
    stmt.executeUpdate(str);
    stmt.close();
    con.commit();
    con.close();
    con=null;
    str=null;
    }catch(Exception e){out.println("Database error!!");}
    %>
    Please help me out and thanks in advance...
    R. Yogaesh.

  • Database Dropdown Population - Newbie, please help

    Hi,
    I am having problems populating a dropdown list in a jsp page with
    mulitple entries from a database. Can anyone please help me with the
    code or point me in the right direction. Im am using the oreily custom
    tags. The page is as follows.
    <%@ page language="java" contentType="text/html" %>
    <%@ page import="java.util.*" %>
    <%@ page import="com.ora.jsp.util.*" %>
    <%@ taglib uri="/orataglib" prefix="ora" %>
    <HTML>
    <BODY>
    <ora:sqlQuery id="sqlAdminDropdown" dataSource="AileenDB"
    scope="session">
    SELECT AdminName From Aministrator
    </ora:sqlQuery>
    <TABLE>
    <TR>
    <TD>
    ** Need to put the dropdown populated with ALL the
    AdminName here **
    </TD>
    </TR>
    </TABLE>
    </BODY>
    </HTML>
    I have tried things like the following but dont have a clue:
    <html:select name="session">
    <html:optionsCollection name="sqlAdminDropdown"
    property="sqlAdminDropdown" labelProperty="AdminName"/>
    </html:select>

    Hi,
    I am having problems populating a dropdown list in a jsp page with
    mulitple entries from a database. Can anyone please help me with the
    code or point me in the right direction. Im am using the oreily custom
    tags. The page is as follows.
    <%@ page language="java" contentType="text/html" %>
    <%@ page import="java.util.*" %>
    <%@ page import="com.ora.jsp.util.*" %>
    <%@ taglib uri="/orataglib" prefix="ora" %>
    <HTML>
    <BODY>
    <ora:sqlQuery id="sqlAdminDropdown" dataSource="AileenDB"
    scope="session">
    SELECT AdminName From Aministrator
    </ora:sqlQuery>
    <TABLE>
    <TR>
    <TD>
    ** Need to put the dropdown populated with ALL the
    AdminName here **
    </TD>
    </TR>
    </TABLE>
    </BODY>
    </HTML>
    I have tried things like the following but dont have a clue:
    <html:select name="session">
    <html:optionsCollection name="sqlAdminDropdown"
    property="sqlAdminDropdown" labelProperty="AdminName"/>
    </html:select>

  • How to acess Database in I18N? Please help.

    How to acess Database in I18N? Please help.

    I have tried to overide the getContents() method of ListResourceBundle class but it returning an error at run time saying null Pointer exception.
    Here are the 2 codes resp.
    import java.util.*;
    public class Test1
         static String string ;
         public static void main(String args[])
    Locale locale = Locale.ENGLISH;
    ResourceBundle myResources =
    ResourceBundle.getBundle("MyResources", locale);
    string = myResources.getString("HelpKey");
    System.out.println(string);
    import java.util.*;
    import java.sql.*;
    public class MyResources extends ListResourceBundle
         static String[][] s3= null;
    String s6= null;
         String s7= null;
    public Object[][] getContents()
    Object[][] obj= (Object[][])dataBase();
              for(int i= 0; i< obj.length;++i){
                   for(int j = 0;j<obj.length;++j){
                        System.out.println("GGGGGGGG obj["+i+"]["+j+"]"+obj[i][j]);
              //s6=(String)obj[0][0];
         //     s6= obj[0][0].toString();
              //s7=obj[1][0].toString();
    Object[][] contents = { {s6},{s7}};
         return contents;
         private static String[][] dataBase()
         {           try
                   Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
                   Connection con=DriverManager.getConnection("jdbc:odbc:DSN");
                   PreparedStatement stat= con.prepareStatement("Select Value,Key from Table1 where Key= ?");
                   String s1= "HelpKey";
                   stat.setString(1,s1);
                   ResultSet rs= stat.executeQuery();
                   while(rs.next())
                        String s2= (String)rs.getString("Key");
                        String s4= (String)rs.getString("Value");
                        String[][] s3 ={{s2},{s4}};
              catch(Exception e)
              e.printStackTrace();
         return s3;

  • I cant access my ymail PLEASE HELP I can log into yahoo but cant get to mail? Think the words configure & rand flash in address bar

    I cant access my ymail PLEASE HELP I can log into yahoo but cant get to mail? Think the words configure & rand flash in address bar

    Hi Acrylik,
    Welcome to the Apple Support Communities!
    For assistance resetting your Apple ID password, please use the information in the following article. I understand you have already attempted to reset via email and security questions, but the article also includes a link to contact Apple support if necessary.
    If you forgot your Apple ID password
    http://support.apple.com/kb/HT5787
    Have a great day,
    Joe

  • My iphone and ipad got stolen in london and I changed the ICLOUD password, now I CANNOT access my ICLOUD. please help...cannot access my find my device.

    my iphone and ipad got stolen in london and I changed the ICLOUD password, now I CANNOT access my ICLOUD. please help...cannot access my find my device

    You can't sign into your iCloud account using the new password on icloud.com on your computer?

  • HT1222 I bought used iPhone and on this iPhone I'm not able to make new account  on i Cloud'.  How can I use this iCloud's on used iPhone   Please help me

    I bought used iPhone and on this iPhone I'm not able to make new account  on i Cloud'.  How can I use this iCloud's on used iPhone   Please help me
    When I logging there it told me that maximum no of iCloud's Account already activated on this iPhone.
    Please help me how can I open new iCloud's account on this iPhone
    Regard
    Faiz khan

    Set up the account using a desktop or laptop, then sign
    into that account on your iPhone.
    I am not aware of any method around the restriction once
    the maximum has been created on any individual iPhne.

  • My ipod touch(4th gen) just recently had the iOS 5 update.bu for some reason about 80% of my music collection appears with no album artwork and doesnt play any songs.basically it has my music on their but wont let me access it? please help!

    My ipod touch(4th gen) just recently had the iOS 5 update.bu for some reason about 80% of my music collection appears with no album artwork and doesnt play any songs.basically it has my music on their but wont let me access it? please help!

    i have the same problem but i have ios 5.01. how do you unsync? please help, thanks

  • HEY, i have some issue i am using macbook air i5...the problem is that without doing anything 1.5gb of ram out of 2gb always in use ..please help me how to make it normal.

    HEY, i have some issue i am using macbook air i5...the problem is that without doing anything 1.5gb of ram out of 2gb always in use ..please help me how to make it normal....
    and my battery back up is max 3 to 3.5 hours in normal use with web ....is this normal or need some betterment!!!!

    ADEEL UR REHMAN wrote:
    ...the problem is that without doing anything 1.5gb of ram out of 2gb always in use
    No computer can do a thing without using memory. 1.5 GB is very little. It's normal.
    3 or so hours from a full charge may also be normal, for what you are doing. As batteries age, they don't last as long on a full charge as they did when they were new. All batteries eventually wear out, and are easily replaceable.

  • In Siri, I can call by my voice, but why I can not use Siri voice call in my country (Laos), just can call only us phone number; my country we use like 3 number for option call, 8 numbers for call friend but Siri cannot use this please help us, thanks

    In Siri, I can call by my voice, but why I can not use Siri voice call in my country (Laos), just can call only us phone number; my country we use like 3 number for option call, 8 numbers for call friend but Siri cannot use this please help us, thanks
    And please help me can type Laos font in it like andrio phone.

    Hi Cozumel,
    Thanks for posting. I'm sorry you're having problems with your bills. I can take a look at this for you. Drop me an email with your account details and a link to this thread for reference. You'll find the address in my profile.
    Cheers
    David
    BTCare Community Mod
    If we have asked you to email us with your details, please make sure you are logged in to the forum, otherwise you will not be able to see our ‘Contact Us’ link within our profiles.
    We are sorry but we are unable to deal with service/account queries via the private message(PM) function so please don't PM your account info, we need to deal with this via our email account :-)

  • An app counting minutes and data use. Please help!!!

    An app counting minutes and data use. Please help!!!

    Here's one, there are others in the App store:
    http://itunes.apple.com/us/app/data-usage/id386950560?mt=8
    However, since your carrier is the one that bills you, the only stats that matter are your carrier's. Some carrier's offer apps that provide this info, see if yours does.

  • HT3209 i want to get old purchased songs and albums back onto my ipod. havent been connected in very long time. now old purchases have this cloud thing on them and i dont know how to access them. someone please help!

    i want to get old purchased songs and albums back onto my ipod. havent been connected in a couple years. old purchases have a cloud on them and wont let me access them. someone please help!

    I have tried that as well.  The purchased songs are not in my playlists and they are still there.  I manually deleted them on the phone but the sync puts them right back on there.
    I only sync playlists and they aren't on there. 

  • Hello! I cant't access home on my IPad after update 7.1.2 .. I slide to open it but i get an empty screen then it turned off and turn on, but still can't access my IPad, please help!!

    hello! I cant't access home on my IPad after update 7.1.2 .. I slide to open it but i get an empty screen then it turned off and turn on, but still can't access my IPad, please help!!

    I had the same problem but looking at what everyone else said, I simpley slowly started to click on all the tabs in the app store, let them load completely, and then clicked back to the updates afterwards. It worked after a little while

Maybe you are looking for

  • The sound file is not getting played in Java1.5 but plays in Java1.4.

    package com.themeapp.general; import java.net.URL; import javax.media.Controller; import javax.media.Manager; import javax.media.Player; import javax.media.Time; public class SoundDemo   public SoundDemo( String resourceName )     System.out.println(

  • Can't Web Browse to 6900 series phones running firmware 9.4.1.3 on cisco CME

    Hi I'm having issues with web browseing to cisco IP phones.  Historically we could web browse to a a basic settings/ dianostics page of the phone by simiply browseing to the phones IP address.  However after an upgrade to SCCP firmware 9.4.1.3 this i

  • Problem with comments when exporting to Excel

    Hi: When opening an exported Numbers file in excel it is showing all the comments opened in fornt of the chart. They can't be closed, have to be deleted one by one. Please take a look at this image: http://gallery.me.com/robbyralston#100124&view=grid

  • How to change subdiretory ownership?

    i am a root user i want to change one diectory's ownership (also including subdirectory's ownership) my command is chown -R newusername:staff directoryname but subdirectory's ownership is not changed. how to do this? thx

  • HT5163 where do I find the Access Point Name?

    I have a iPhone 4s and changed my sims card, the new provider instructions are to change my "Access Point Name" to get date