What is wrong with my tiny jdbc program? Help!!!

Hi,
Would anyone diagnose the problem of my simple jdbc program?
The situation is :
a) local machine oracle thin driver connection; "lsnrctl" is running.
b) I can query the statement "select id from gameUser" from SQLPLUS logged in as "scott", with desirable result.
c) There are two code lines commented out in the code, if I uncomment them and instead comment out their counterparts and run the program, the "rset" would contain the result I want. But if I run the program unchanged, the output is only "hi".
d) If I change the query statement to a wrong column name or a wrong table name, there would be a sql exception. So I surmise that the connection with the database is successful. But how come there is no query result???
The follow is my coding.
import java.sql.*;
class dbAccess {
public static void main (String args []) throws SQLException
DriverManager.registerDriver (new oracle.jdbc.driver.OracleDriver());
try{
Connection conn = DriverManager.getConnection
("jdbc:oracle:thin:orcl", "scott", "tiger");
// ("jdbc:oracle:thin:orcl", "system", "manager");
Statement stmt = conn.createStatement();
ResultSet rset = stmt.executeQuery("select ID from scott.gameUser");
// ResultSet rset = stmt.executeQuery("select BANNER from SYS.V_$VERSION");
while (rset.next())
System.out.println (rset.getString(1)); stmt.close();
System.out.println("hi");
}catch (Exception e)
System.out.println(e.toString());
Thanks for help!

"local machine oracle thin driver connection;" means that my jdbc application uses Oracle thin driver to connect to a Oracle database. The database and the application are both on the same local machine.
"lsnrctl" is the command line program running to accept incomming request to connect to the database, it listens on the default 1521 port.
I inserted two rows into the table and I could query these two rows in SQLPLUS.
And I tried "select ID from gameUser", "select id from scott.gameUser" and various combination, it just won't retrieve the rows I inserted in the table.

Similar Messages

  • What's wrong with my code? please help....

    when display button is clicked it must diplay the remarks but it didn't happen...
    what's wrong with my code? please help
    here is my code.....
    import java.applet.Applet;
    import java.awt.*;
    import java.awt.event.*;
    public class Area extends Applet implements ItemListener,ActionListener
         {Label arlbl = new Label("AREA");
          Choice archc = new Choice();
          Label extlbl = new Label("EXPENDITURE TYPE");
          CheckboxGroup extchk = new CheckboxGroup();
              Checkbox fchk = new Checkbox("FOOD",extchk,true);
              Checkbox schk = new Checkbox("SHELTER",extchk,false);
              Checkbox echk = new Checkbox("EDUCATION",extchk,false);
              Checkbox uchk = new Checkbox("UTILITIES",extchk,false);
          Label exalbl = new Label("EXPENDITURE AMOUNT");
          TextField exatf = new TextField("",20);
          Label remlbl = new Label("REMARKS");
          TextField remtf = new TextField("",30);
          Button disbtn = new Button("DISPLAY");
          Button resbtn = new Button("RESET");
          String display;
          public void init()
              {add(arlbl);
               archc.add("MANILA");
               archc.add("MAKATI");
               archc.add("QUEZON");
               archc.add("PASAY");
               add(archc);
               archc.addItemListener(this);
               add(extlbl);
               add(fchk);
               fchk.addItemListener(this);
               add(schk);
               schk.addItemListener(this);     
               add(echk);
               echk.addItemListener(this);
               add(uchk);
               uchk.addItemListener(this);
               add(exalbl);
               add(exatf);
               add(remlbl);
               add(remtf);
               add(disbtn);
               disbtn.addActionListener(this);
               add(resbtn);
               resbtn.addActionListener(this);
         public void itemStateChanged(ItemEvent ex)
              {int n = archc.getSelectedIndex();
               if(n==0)
                   {if(fchk.getState())
                         {exatf.setText("10000.00");
                         display = archc.getSelectedItem();
                   if(schk.getState())
                        {exatf.setText("15000.00");
                        display = archc.getSelectedItem();
                   if(echk.getState())
                        {exatf.setText("24000.00");
                        display = archc.getSelectedItem();
                   if(uchk.getState())
                        {exatf.setText("8500.00");
                        display = archc.getSelectedItem();
              if(n==1)
                   {if(fchk.getState())
                        {exatf.setText("5000.00");
                        display = archc.getSelectedItem();
                   if(schk.getState())
                        {exatf.setText("11000.00");
                        display = archc.getSelectedItem();
                   if(echk.getState())
                        {exatf.setText("7500.00");
                        display = archc.getSelectedItem();
                   if(uchk.getState())
                        {exatf.setText("24000.00");
                        display = archc.getSelectedItem();
              if(n==2)
                   {if(fchk.getState())
                        {exatf.setText("13000.00");
                        display = archc.getSelectedItem();
                   if(schk.getState())
                        {exatf.setText("7000.00");
                        display = archc.getSelectedItem();
                   if(echk.getState())
                        {exatf.setText("27000.00");
                        display = archc.getSelectedItem();
                   if(uchk.getState())
                        {exatf.setText("6000.00");
                        display = archc.getSelectedItem();
              if(n==3)
                   {if(fchk.getState())
                        {exatf.setText("6000.00");
                        display = archc.getSelectedItem();
                   if(schk.getState())
                        {exatf.setText("9000.00");
                        display = archc.getSelectedItem();
                   if(echk.getState())
                        {exatf.setText("15000.00");
                        display = archc.getSelectedItem();
                   if(uchk.getState())
                        {exatf.setText("19000.00");
                        display = archc.getSelectedItem();
         public void actionPerformed(ActionEvent e)
              {if(e.getSource() == disbtn)
                    {String amtstr = exatf.getText();
                     int amt = Integer.parseInt(amtstr);
                        {if(amt > 8000)
                             {remtf.setText(display + " IS ABOVE BUDGET");
                        else
                             {remtf.setText(display + " IS BELOW BUDGET");
              if(e.getSource() == resbtn)
                   {archc.select(0);
                   fchk.setState(true);
                   schk.setState(false);
                   echk.setState(false);
                   uchk.setState(false);
                   exatf.setText("");
                   remtf.setText("");
    Edited by: lovely23 on Feb 28, 2009 11:24 PM

    Edit: thanks for cross-posting this question on another forum. I now see that I wasted my time trying to study your code in the java-forums to help you with an answer that had already been answered elsewhere (here). Do you realize that we are volunteers, that our time is as valuable as yours? Apparently not. Cross-post again and many here will not help you again. I know that I won't.

  • When i use the apple store, Your request is temporarily unable to be processed. what is wrong with it? can someone help me?

    when i use the apple store, Your request is temporarily unable to be processed. what is wrong with it? can someone help me?

    Try turning off the Firewall in System Preferences > Security (or Security & Privacy) > Firewall
    Disable anti virus software if you have that installed before downloading media from the App Store.
    When you post for help, please tell us which Mac OS X you have installed. Thanks !

  • What is wrong with this class? Please help

    I'm trying to sort a dynamically created JComboBox into Alphabetical order. However, the class below is the result of my coding and there is a problem. the code can sort only two(2) item in the JComboBox and no more which is wrong. I do not know where i'm going wrong in the selectionSort(JComboBox cmb) method. the getLargest(JComboBox cmb) method works perfectly because i have tried it. Can somebody please take a look at my codes and help me modify it.
    Thanks
    James
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import javax.swing.event.*;
    public class SortCombo extends JFrame implements ActionListener{
    JButton btnAdd, btnSort;
    JComboBox cmbItems;
    JTextField text1;
    public SortCombo(){
    super("Sorting Demo");
    this.getContentPane().setLayout(new GridLayout(4,1));
    this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    btnAdd = new JButton("Add Item to Combo Box");
    btnSort = new JButton("Sort Items in ComboBox");
    text1 = new JTextField(20);
    cmbItems = new JComboBox();
    btnAdd.addActionListener(this);
    btnSort.addActionListener(this);
    this.getContentPane().add(cmbItems);
    this.getContentPane().add(text1);
    this.getContentPane().add(btnAdd);
    this.getContentPane().add(btnSort);
    this.pack();
    this.show();
    public void actionPerformed(ActionEvent e){
    if(e.getSource() == btnAdd){
    String s = text1.getText();
    if (!s.equals("") && !isDuplicate(s,cmbItems))
    cmbItems.addItem(text1.getText());
    }else if(e.getSource() == btnSort){
    selectionSort(cmbItems);
    // int i = getLargest(cmbItems);
    // System.out.println(i);
    public boolean isDuplicate(String stationName, JComboBox cmb){
    int j = cmb.getItemCount();
    boolean result = false;
    for (int i = 0; i < j; i++){
    String s = (String)cmb.getItemAt(i);
    if (stationName.trim().equalsIgnoreCase(s.trim()))
    result = true;
    return result;
    public int getLargest(JComboBox cmb){
    int indexSoFar = 0;
    int size = cmb.getItemCount();
    for(int currIndex = 1; currIndex < size; currIndex++){
    String strSoFar = (String)cmb.getItemAt(indexSoFar);
    String currStr = (String)cmb.getItemAt(currIndex);
    char charSoFar = strSoFar.charAt(0); charSoFar = Character.toUpperCase(charSoFar);
    char currChar = currStr.charAt(0); currChar = Character.toUpperCase(currChar);
    if(currChar > charSoFar){
    indexSoFar = currIndex;
    return indexSoFar;
    public void selectionSort(JComboBox cmb){
    int n = cmb.getItemCount();
    for (int last = n-1; last >=1; last--){
    int largest = getLargest(cmb);
    String temp = (String)cmb.getItemAt(largest);
    String temp2 = (String)cmb.getItemAt(last);
    cmb.removeItemAt(largest);
    cmb.insertItemAt(temp2,largest);
    cmb.removeItemAt(last);
    cmb.insertItemAt(temp,last);
    public static void main(String[] args){
    new SortCombo();
    }

    I beleive what is wrong is that your getLargest method returns the largest to your selection sort.The selectionSort places the largest at the end.On the next iteration it finds the largest again. this time at the end where you put it.Now it just does the same thing over again placing the same item at the end until the loop runs out.What you are left with is only one item it the right spot(sometimes 2).I could not get it to work the way you had it here so I tried a rewrite.It seems to work ok but it won't sort two words that start with the same letter properly.You may have to insert an algorithm to fix this.I got rid of the getLargest method and did everything in the selectionSort method.I used what I think is called a bubble sort but I'm not sure.
    I hope this is what you were looking for:)
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import javax.swing.event.*;
    public class SortCombo extends JFrame implements ActionListener{
         JButton btnAdd, btnSort;
         JComboBox cmbItems;
         JTextField text1;
         public SortCombo(){
              super("Sorting Demo");
              getContentPane().setLayout(new GridLayout(4,1));
              setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
              btnAdd = new JButton("Add Item to Combo Box");
              btnSort = new JButton("Sort Items in ComboBox");
              text1 = new JTextField(20);
              cmbItems = new JComboBox();
              btnAdd.addActionListener(this);
              btnSort.addActionListener(this);
              Container pane = getContentPane();
              pane.add(cmbItems);
              pane.add(text1);
              pane.add(btnAdd);
              pane.add(btnSort);
              pack();
              show();
         public void actionPerformed(ActionEvent e){
              if(e.getSource() == btnAdd){
              String s = text1.getText();
              if (!s.equals("") && !isDuplicate(s,cmbItems))
              cmbItems.addItem(text1.getText());
              }else if(e.getSource() == btnSort){
              selectionSort(cmbItems);
         public boolean isDuplicate(String stationName, JComboBox cmb){
              int j = cmb.getItemCount();
              boolean result = false;
              for (int i = 0; i < j; i++){
                   String s = (String)cmb.getItemAt(i);
                   if (stationName.trim().equalsIgnoreCase(s.trim()))
                   result = true;
              return result;
         public void selectionSort(JComboBox cmb){
              int count = cmb.getItemCount();
              for(int start = 0;start < count;start++){
                   for(int x = start;x < count-1;x++){
                        String first = (String)cmb.getItemAt(start);
                        String next = (String)cmb.getItemAt(x+1);
                        char charFirst = first.charAt(0);
                               charFirst = Character.toUpperCase(charFirst);
                        char charNext = next.charAt(0);
                        charNext = Character.toUpperCase(charNext);
                             if(charFirst > charNext){
                                  String temp  = (String)cmb.getItemAt(start);
                                  String temp2 = (String)cmb.getItemAt(x+1);
                                  cmb.removeItemAt(start);
                                  cmb.insertItemAt(temp2,start);
                                  cmb.removeItemAt(x+1);
                                  cmb.insertItemAt(temp,x+1);
         public static void main(String[] args){
              new SortCombo();
    }p.s.(I removed the "this" references from your constructor when I rewrote it because they are implied anyway)
    [email protected]

  • What's wrong with this code. Any Help please?

    Hello
    I'm a newbie to java programming.I got this sample code from an online book that I use in learning java and I'm trying to run the code on eclipse but I got this error message
    "Fatal exception occurred. Programm will exit."
    This is the code:
    public class MostDivisors {
         public static void main(String[] args) {
              int N;
              int maxDivisors;
              int numWithMax;
              maxDivisors = 1;
              numWithMax = 1;
              for(N = 2 ; N <= 10000 ; N++){
                   int D;
                   int divisorCount;
                   divisorCount = 0;
                   for(D=0; D <= N; D++){
                        if (N % D == 0)
                             divisorCount++;
                   if (divisorCount > maxDivisors){
                        maxDivisors = divisorCount;
                        numWithMax = N;
              System.out.println("Among intergers between 1 and 10000,");
              System.out.println("The maximum number of divisors is "+maxDivisors);
              System.out.println("A number with " + maxDivisors + " divisors is ");
    Any Help will be appreciated. Thank you all for helping me out understand the problem here

    Thank you all participating to help this out.
    This is the code and the detailed error message:
    public class MostDivisors {
         public static void main(String[] args) {
              int N;
              int maxDivisors;
              int numWithMax;
              maxDivisors = 1;
              numWithMax = 1;
              for(N = 2 ; N <= 10000 ; N++){
                   int D;
                   int divisorCount;
                   divisorCount = 0;
                   for(D=0; D <= N; D++){
                        if (N % D == 0)
                             divisorCount++;
                   if (divisorCount > maxDivisors){
                        maxDivisors = divisorCount;
                        numWithMax = N;
              System.out.println("Among intergers between 1 and 10000,");
              System.out.println("The maximum number of divisors is "+maxDivisors);
              System.out.println("A number with " + maxDivisors + " divisors is ");
    ERROR MESSAGE starts HERE:
    java.lang.ArithmeticException: / by zero
         at MostDivisors.main(MostDivisors.java:30)
    Exception in thread "main"
    I do not think this is related to the JVM because other programs will compile and run successfully.
    Any Help will be appreciated. Thanks

  • What is wrong with my simple class program?

    Ok, I'm writing a simple class called 'Frog', which will keep track of the position enter by a user. The program will ask for the initial position for the frog. It will then ask for how many steps it want the frog to jump. Then it will output the new position of it. But for some reason, it doesn't work. It always output 0 for some reason.
    import java.io.*;
    import java.util.*;
    - frog program class.
    frog will start on a position.
    user will be prompt to ask how many jump to forward.
    public class beta
         public static void main(String args[]) throws IOException
              class Frog
              int newPos;
                   int Position () //return postion of the frog
                   return newPos;
                   void PositionStart (int newPos) //initial postion of the frog
                   newPos = newPos;
                   int Jump(int stepsForward, int newPos)
                        newPos+=stepsForward;
                        return newPos;
                   int PrevPos(int newPos)
                   return newPos-1;
                   int NextPos(int newPos)
                   return newPos+1;
                   boolean isMagicSquare(int newPos)
                        if(newPos == 5) return true;
                        else return false;
         BufferedReader key = new BufferedReader(new InputStreamReader(System.in));
         Frog joe = new Frog();
         int pos = 0, stepsFoward = 0;
                   //input 1-9
                   do
                        System.out.println("Enter a position for the frog: ");
                        pos = Integer.parseInt(key.readLine()); //reads in an integer
                   }while(pos < 1 || pos > 9);
                   joe.PositionStart(pos); //initialize the position for the frog
                   System.out.println("Pos: " + joe.Position()); //position
                   System.out.println("How many steps to jump: ");
                   stepsFoward = Integer.parseInt(key.readLine());
                   joe.Jump(stepsFoward,joe.Position());
                   System.out.println("New Position: " + joe.Position());               
    }

    You have method argument parameters with the same name as a member variable; as in:
    void PositionStart (int newPos) {
            newPos = newPos;
    }You need to identify to the compiler which variable is which, class member variables in cases like this should be qualified with the this keyword; as in:
    void PositionStart (int newPos) {
            this.newPos = newPos;
    }Dave

  • What's wrong with my transform? Please help!

    I have a program which is trying to transform some XML data into HTML. I'm using DOM, and am selecting a node with getElementByID(). This Node is then passed to the transformer, and the data it contains should be output with HTML markup. However, the transform outputs the XML data, but with none of the HTML formatting contained in the XSL! I have a very simple program here to demonstrate what I mean
    Here's the XML:
    <?xml version="1.0" encoding="UTF-8"?>
    <people xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:noNamespaceSchemaLocation="file:/C:/test.xsd">
        <person employee_no="e124">
            <name>Mary Jane</name>
            <address>420 High St</address>
            <phone>555-0123</phone>
        </person>
        <person employee_no="e123">
            <name>John Smith</name>
            <address>123 Boulevard Rd</address>
            <phone>555-0918</phone>
        </person>
    </people>Here's the XSL:
    <?xml version="1.0" encoding="UTF-8"?>
    <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
        <xsl:output method="html"/>
            <xsl:template match="/">
                <html>
                        <p>Name: <xsl:value-of select="person/name"/><br/>Address: <xsl:value-of select="person/address"/><br/>Phone: <xsl:value-of select="person/phone"/></p>
                </html>
            </xsl:template>
    </xsl:stylesheet>And here's the code that is giving me problems - it selects a node using getElementByID and tries to apply that node to the transform.
    package xsltest;
    import java.io.*;
    import javax.xml.transform.stream.*;
    import javax.xml.transform.dom.*;
    import javax.xml.parsers.*;
    import javax.xml.transform.*;
    import org.w3c.dom.*;
    import org.apache.xerces.parsers.*;
    public class XSLTest {
      String xslPath = "C:\\test.xsl";
      String xmlPath = "C:\\test.xml";
      String xsdPath = "C:\\test.xsd";
      String outPath = "c:\\XSLTest.html";
      org.w3c.dom.Document xmlDoc;
      public XSLTest() {
        /*Load the XML file, with Schema validation turned on*/
        try {
            DOMParser parser = new DOMParser();
            parser.setFeature("http://xml.org/sax/features/validation", true);
            parser.setFeature("http://apache.org/xml/features/validation/schema", true);
            parser.parse(xmlPath);
            xmlDoc = parser.getDocument();
        catch (Exception e) { e.printStackTrace(); }
        File outFile = new File(outPath);
        File xslFile = new File(xslPath);
        StreamResult result = new StreamResult(outFile);
        StreamSource xsltSource = new StreamSource(xslFile);
        /*Select the element that we wish to output HTML for*/
        Node node = xmlDoc.getElementById("e124");
        DOMSource xmlSource = new DOMSource(node);
        try {
          javax.xml.transform.TransformerFactory tff = TransformerFactory.newInstance();
          Transformer transformer = tff.newTransformer(xsltSource);
          transformer.transform(xmlSource, result);
        catch (Exception e) {
          e.printStackTrace();
      public static void main(String[] args) {
        XSLTest test = new XSLTest();
    }When I do this, I get an empty document containing only:
    Mary Jane 420 High St 555-0123
    What am i doing wrong here?

    Hello,
    try this:
    change the line
    Node node = xmlDoc.getElementById("e124");
    with this content:
    Node node = null;
    org.w3c.dom.NodeList theList = xmlDoc.getElementsByTagName("person");
    for (int i = 0; i < theList.getLength(); i++)
    if ( ( (org.w3c.dom.Element) theList.item(i)).getAttribute("employee_no").equalsIgnoreCase("e124"))
    node=theList.item(i);
    The problem is, that the method "getElementByID" delivers "null" in your code.

  • What is wrong with this!! please help

    Hello friends,
    I'm a learner and I have done lot of JDBC connectivity with Acess database, and now I want to connect java program with oracle database, but the problem is I have downloaded the oracle driver, set the classpath, and I have created the DataSource Name with MS-ODBC, I could able to compile but I'm getting run time exception, please help me with this. regards, shabeer.
    the program is
    import java.sql.*;
    public class ShabeerJdbc {
    public static void main(String args[]) {
    // String url = "jdbc:oracle:thin:@imran:3339:shabeerjdbc";
    Connection con;
    String createString;
    createString = "create table COFFEES " +
    "(COF_NAME VARCHAR(32), " +
    "SUP_ID INTEGER, " +
    "PRICE FLOAT, " +
    "SALES INTEGER, " +
    "TOTAL INTEGER)";
    Statement stmt;
    try {
    System.out.println("shabeer1");
    Class.forName("oracle.jdbc.driver.OracleDriver").newInstance();
    System.out.println("shabeer2");
    } catch(java.lang.Exception e) {
    System.out.println("shabeer3");
    System.err.print("ClassNotFoundException: ");
    System.out.println("shabeer4");
    System.err.println(e.getMessage());
    try {
    System.out.println("shabeer55");
    con = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:shabeerjdbc", "system", "mehar");
    System.out.println("shabeer6");
    stmt = con.createStatement();
    System.out.println("shabeer7");
    stmt.executeUpdate(createString);
    stmt.close();
    con.close();
    } catch(SQLException ex) {
    System.err.println("SQLException: " + ex.getMessage());
    the run time error is ......
    C:\JavaPractice>java ShabeerJdbc
    shabeer1
    shabeer2
    shabeer55
    Exception in thread "main" java.lang.NoClassDefFoundError: java/sql/Savepoint
    at java.lang.ClassLoader.defineClass0(Native Method)
    at java.lang.ClassLoader.defineClass(Unknown Source)
    at java.security.SecureClassLoader.defineClass(Unknown Source)
    at java.net.URLClassLoader.defineClass(Unknown Source)
    at java.net.URLClassLoader.access$100(Unknown Source)
    at java.net.URLClassLoader$1.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClassInternal(Unknown Source)
    at oracle.jdbc.driver.OracleDriver.getConnectionInstance(OracleDriver.ja
    va:468)
    at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:314)
    at java.sql.DriverManager.getConnection(Unknown Source)
    at java.sql.DriverManager.getConnection(Unknown Source)
    at ShabeerJdbc.main(ShabeerJdbc.java:38)
    ****************************************

    HI Deriderj, thanks for your response, well I have changed the Datasourse name to SID which is "Imran" and still it is not working....do I need to download anymore driver or whether they be bundled with the ojdbc.jar, please advice me. What if I want to use another driver as you mentioned...not to use thin: what other drivers will be available for the Oracle9.2.0.1.0 please advice me, thanks a lot
    My SID name is "Imran"
    listening port is is 1521
    odbc datasource name is "shabeerjdbc"
    I'm a very biginner and I'm facing too much problem, please help me. Well I have got Oracle9.2.0.1.0 loaded as the database and soon after I intstalled it I have copied ojdbc14.jar into my java classpath and I'm trying to connect to this data base. I dont know what driver I should use, neither I downloaded any. I'm just mentioning thin: in my URL. But It is giving error, can u please tell me what driver should I mention in the URL, and why I'm getting this error, Here is the code that is compiling without errors.
    import java.sql.*;
    public class ShabeerJdbc {
    public static void main(String args[]) {
    Connection con;
    String createString;
    createString = "create table COFFEES " +
    "(COF_NAME VARCHAR(32), " +
    "SUP_ID INTEGER, " +
    "PRICE FLOAT, " +
    "SALES INTEGER, " +
    "TOTAL INTEGER)";
    Statement stmt;
    try {
         System.out.println("shabeer1");
    Class.forName("oracle.jdbc.driver.OracleDriver").newInstance();
         System.out.println("shabeer2");
    } catch(java.lang.Exception e) {
         System.out.println("shabeer3");
    System.err.print("ClassNotFoundException: ");
         System.out.println("shabeer4");
    System.err.println(e.getMessage());
    try {
         System.out.println("shabeer55");
    con = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:Imran", "system", "mehar");
         System.out.println("shabeer6");
         stmt = con.createStatement();
         System.out.println("shabeer7");
         stmt.executeUpdate(createString);
    stmt.close();
    con.close();
    } catch(SQLException ex) {
    System.err.println("Sql Exception" + ex.getMessage());
    ************The runtime Error it is giving is *********************
    C:\JavaPractice>java ShabeerJdbc
    shabeer1
    shabeer2
    shabeer55
    Exception in thread "main" java.lang.NoClassDefFoundError: java/sql/Savepoint
    at oracle.jdbc.driver.OracleDriver.getConnectionInstance(OracleDriver.ja
    va:468)
    at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:314)
    at java.sql.DriverManager.getConnection(Unknown Source)
    at java.sql.DriverManager.getConnection(Unknown Source)
    at ShabeerJdbc.main(ShabeerJdbc.java:38)
    ***************************** please help me....

  • What's wrong with this sql query?  Help

    hi
    i am having difficulty executing this query
    ResultSet s=st.executeQuery("select * from employee where iden = ?"+id);
    here in my program st is statement obg
    iden is attribute name in table
    id i am getting at run time from user
    please help...it says wrong number of parameters
    thank you

    That's correct, get rid of the Question mark. Questions marks are used in PreparedStatements, but they are also used in pattern matching. I am assuming the iden is the table identity. Therefore, I am assuming it is numeric. If so, you can't use the question mark because pattern matching is only done with strings. If you are treating your statement as a PreparedStatement, then you have done it wrong. (See the API) Here is a code snippet from the API:PreparedStatement pstmt =     
       con.prepareStatement("UPDATE EMPLOYEES SET SALARY = ? WHERE ID = ?");
    pstmt.setBigDecimal(1, 153833.00)
    pstmt.setInt(2, 110592)It seems you are using a Statement object, so, you need to get rid of that question mark.
    tajenkins

  • Iphoto update is messed how, i do i fix it. Photos that i try to sync aren't showing up in my "Last Import" or "Last Month" What's wrong with it? I need help a.s.a.p

    please i need help on this. I really need to fix this

    Remember: we cannot see your machine. There are 9 different versions of iPhoto and they run on 8 different versions of the Operating System. The tricks and tips for dealing with issues vary depending on the version of iPhoto and the version of the OS.  So to get help you need to give as much information as you can. Basic things like :
    - What version of iPhoto.
    - What version of the Operating System.
    - Details. As full a description of the problem as you can. For instance: 'iPhoto won't export' is best explained by describing how you are trying to export, and so on.
    - History: Is this going on long? Has anything been installed or deleted?
    - Are there error messages?
    - What steps have you tried already to solve the issue.
    - Anything unusual about your set up? Or how you use iPhoto?
    Anything else you can think of that might help someone understand the problem you have.
    Posts that consist of "iPhoto doesn't work. Help" or "iPhoto won't print" or "Suddenly I have no photos!!!!!!!!!!" mean that any helper is simply guessing. More information means you get better assistance.

  • What is wrong with my iBook?  Please help!!!

    Sometimes it will load OSX and then freeze up, sometimes it will freeze up while loading OSX, sometimes it won't do anything besides play the start noise. I have noticed that if I whack at the laptop in the area where the hard drive is located it will typically work, at least for a while. I am pretty sure it is my hard drive going bad, but it has also been like 2 years since I cleaned everything out and restored it.
    I carry this laptop everywhere. It goes with me to the coffee shops, classes, resturants, extented trips, everywhere. So I am thinking that through the constant moving and bumping and what ever else it has gone through so hardware componet may be reaching its limit on use.
    If anyone has an idea about what to do I would love to know too.
    P.S. It won't even run the restart CD's with out freezing up. But like I said I hit it and then it will work okay again for a while. It is working okay right now, although this is the second time that I had to restart cause the first time it froze up a few minutes after the OS loaded.

    If you are unable to start up to the install disc then there is something other than the hard drive not working properly. When you start up to the install disc, the computer is not using the hard drive, so any issues that happen when trying to boot to the DVD indicate issue with other parts.
    My best advice is to back up your data, try to run Disc utility on the HD to see if it finds any errors, repair those errors while booted to the DVD. If you can boot to the disc and verify the HD but are unable to repair you can try Disc Warrior, it saved me from needing to do an erase and install. If your unable to do that, again with your data backed up, Erase the HD and reinstall OS 10, sometimes the hard drive errors can be fixed by erasing and starting over.
    Heres Apples article on running disc utility
    http://docs.info.apple.com/article.html?artnum=106214
    If your unable to boot to the disc take it to an authorized provider and have them check it out. I'll cross my fingers for you that you have Apple care otherwise it can be pretty costly to fix.
    Good Luck

  • What is wrong with my Code?  Please Help!

    I am using a case statement to convert a DOB to Age. I have used this before on another oracle database and it worked fine. Now I am getting and error ORA-00909 invalid number of arguments; Can someone take a look at it and let me know why this is erroring out? Thanks!!
    SELECT
    PWLDBA.TESTREQ.ACCESSION,
    PWLDBA.ENCOUNTER.ENCOUNTERNO,
    PWLDBA.PATIENT.NAMELAST,
    PWLDBA.PATIENT.NAMEFIRST,
    PWLDBA.PATIENT.NAMEINITIAL,
    PWLDBA.PATIENT.NAMESUFFIX,
    PWLDBA.PATIENT.ADDR2,
    PWLDBA.PATIENT.ADDR1,
    PWLDBA.PATIENT.CITY,
    PWLDBA.PATIENT.STATE,
    PWLDBA.PATIENT.COUNTRY,
    PWLDBA.PATIENT.PHONE,
    PWLDBA.PATIENT.DOB,
    CASE WHEN MONTHS_BETWEEN(SYSDATE, TO_DATE(TO_CHAR(PWLDBA.PATIENT.DOB), 'YYYYMMDD')) < 1 THEN
    TRUNC((SYSDATE - TO_DATE(TO_CHAR(PWLDBA.PATIENT.DOB), 'YYYYMMDD'))/7) || ' WEEKS'
    WHEN MONTHS_BETWEEN(SYSDATE, TO_DATE(TO_CHAR(PWLDBA.PATIENT.DOB), 'YYYYMMDD')) < 12 THEN
    TRUNC(MONTHS_BETWEEN(SYSDATE, TO_DATE(TO_CHAR(PWLDBA.PATIENT.DOB), 'YYYYMMDD'))) || ' MONTHS'
    ELSE TRUNC(MONTHS_BETWEEN(SYSDATE, TO_DATE(PWLDBA.PATIENT.DOB), 'YYYYMMDD'))/12) || ' YEARS'
    END AS AGE
    PWLDBA.PATIENT.GENDER,
    PWLDBA.PATIENT.ITKEY_0,
    PWLDBA.PATIENT.GROUP_0,
    PWLDBA.PATIENT.SSN,
    PWLDBA.SF.SRCFAC,
    PWLDBA.SF.SRCFACNAME,
    PWLDBA.PATIENT.PID,
    PWLDBA.TESTREQ.COMPLETED,
    PWLDBA.TESTREQ.RDKEY_0,
    PWLDBA.TESTREQ.REFPNAME_0,
    PWLDBA.TESTREQ.REQUESTTYPE,
    PWLDBA.TESTREQ.STATUS,
    PWLDBA.TESTREQ.SOURCE,
    PWLDBA.TESTREQ.COLLECTED,
    PWLDBA.TESTREQ.RECEIVED,
    PWLDBA.TESTREQ.COMPLETED,
    PWLDBA.RD.REFPNAME,
    PWLDBA.RD.NAMELAST,
    PWLDBA.RD.NAMEINITIAL,
    PWLDBA.RD.NAMESUFFIX,
    PWLDBA.RD.SPCL_SSKEY,
    PWLDBA.RD.PROVIDERID,
    PWLDBA.RD.ADDR1,
    PWLDBA.RD.ADDR2,
    PWLDBA.RD.ADDR2,
    PWLDBA.RD.CITY,
    PWLDBA.RD.STATE,
    PWLDBA.RD.ZIP,
    PWLDBA.RD.CONTACTPHONE,
    PWLDBA.RD.NPI,
    PWLDBA.RD.UPIN,
    PWLDBA.TESTREQ.COLLECTED AS PRIMARY_COL_DT,
    PWLDBA.TESTREQ.RECEIVED AS PRIMARY_REC_DT,
    PWLDBA.PTRESULT.FINALSTAMP AS FINAL_COMP_DT,
    PWLDBA.TEST.NAME,
    PWLDBA.TEST.SHORTNAME,
    PWLDBA.TESTREQ.OS_SITEKEY,
    PWLDBA.PTRESULT.TYPE,
    PWLDBA.PTRESULT.SOURCE,
    PWLDBA.PTRESULT.STATUS,
    PWLDBA.PTRESULT.UNITS,
    PWLDBA.PTRESULT.NORMAL,
    PWLDBA.PTRESULT.ABNRANGE,
    PWLDBA.PTRESULT.VVRANGE,
    PWLDBA.PTRESULT.SCALE,
    PWLDBA.TESTREQ.COLLECTED,
    PWLDBA.PATIENT.PID,
    PWLDBA.PT.DESCRIPTION AS CASE_TYPE,
    PWLDBA.TEST.NAME,
    PWLDBA.TEST.TESTCODE,
    PWLDBA.TESTREQ.ICD9KEY_0,
    CASE WHEN MONTHS_BETWEEN(SYSDATE, TO_DATE(TO_CHAR(PWLDBA.PATIENT.DOB), 'YYYYMMDD')) < 1 THEN
    TRUNC((SYSDATE - TO_DATE(TO_CHAR(PWLDBA.PATIENT.DOB), 'YYYYMMDD'))/7) || ' WEEKS'
    WHEN MONTHS_BETWEEN(SYSDATE, TO_DATE(TO_CHAR(PWLDBA.PATIENT.DOB), 'YYYYMMDD')) < 12 THEN
    TRUNC(MONTHS_BETWEEN(SYSDATE, TO_DATE(TO_CHAR(PWLDBA.PATIENT.DOB), 'YYYYMMDD'))) || ' MONTHS'
    ELSE TRUNC(MONTHS_BETWEEN(SYSDATE, TO_DATE(PWLDBA.PATIENT.DOB), 'YYYYMMDD'))/12) || ' YEARS'
    END AS AGE
    FROM
    PWLDBA.PATIENT
    INNER JOIN PWLDBA.SF
    ON PWLDBA.PATIENT.SFKEY = PWLDBA.SF.SFKEY
    INNER JOIN PWLDBA.ENCOUNTER
    ON PWLDBA.ENCOUNTER.PATIENTKEY = PWLDBA.PATIENT.PATIENTKEY
    INNER JOIN PWLDBA.TESTREQ
    ON PWLDBA.PATIENT.PATIENTKEY = PWLDBA.TESTREQ.PATIENTKEY
    INNER JOIN PWLDBA.RD
    ON PWLDBA.TESTREQ.RDKEY_0 = PWLDBA.RD.RDKEY
    INNER JOIN PWLDBA.PTRESULT
    ON PWLDBA.TESTREQ.TESTREQKEY = PWLDBA.PTRESULT.TESTREQKEY
    INNER JOIN PWLDBA.TEST
    ON PWLDBA.TEST.TESTKEY = PWLDBA.TESTREQ.TESTKEY
    lEFT OUTER JOIN PWLDBA.PT
    ON PWLDBA.PATIENT.PATIENTKEY=PWLDBA.PT.PTKEY
    WHERE PWLDBA.TEST.NAME LIKE 'HPV%' AND PWLDBA.TESTREQ.STATUS ='D'

    Should be something as simple as this I would have thought...
    SQL> ed
    Wrote file afiedt.buf
      1  with t as (select date '1972-07-01' as dob from dual union all
      2             select date '1999-12-28' from dual union all
      3             select date '2011-01-11' from dual union all
      4             select date '2011-01-14' from dual union all
      5             select date '2011-10-01' from dual union all
      6             select date '2011-10-08' from dual)
      7  --
      8  -- end of test data
      9  --
    10  select dob
    11        ,case when sysdate-dob < 7 then
    12                -- less than 1 week, show in days
    13                floor(sysdate-dob)||' day(s)'
    14              when months_between(trunc(sysdate), trunc(dob)) < 1 then
    15                -- less than 1 month
    16                floor((sysdate-dob)/7)||' week(s)'
    17              when months_between(trunc(sysdate), trunc(dob)) < 12 then
    18                floor(months_between(trunc(sysdate), trunc(dob)))||' month(s)'
    19         else floor((months_between(trunc(sysdate), trunc(dob)))/12)||' year(s)'
    20         end as age
    21* from t
    SQL> /
    DOB         AGE
    01-JUL-1972 39 year(s)
    28-DEC-1999 11 year(s)
    11-JAN-2011 9 month(s)
    14-JAN-2011 8 month(s)
    01-OCT-2011 1 week(s)
    08-OCT-2011 3 day(s)
    6 rows selected.

  • What's wrong with my codes? Please help!

    *Questions are #13 and #14. These should be combined.
    Can you please tell me why the following is not answering the questions #13 and #14?
    Thank you!!
    import java.util.Scanner;               // Needed for Scanner class
    import java.text.DecimalFormat;          // Needed for DecimalFormat class
         #13:
              An Internet service provider has three different subscription
              packages for its customers:
              Package A:          For $9.95 per month 10 hours of access are provided.
                                  Additional hours are $2.00 per hour.
              Package B:          For $13.95 per month 20 hours of access are provided.
                                  Additional hours are $1.00 per hour.
              Package C:          For $19.95 per month unlimited access is provided.
              Write a program that calculates a customer's monthly bill. It should
              ask the user to enter the letter of the package the customer has
              purchased (A, B, or C) and the number of hours that were used. It should
              then display the total charges.
         #14:
              Modify the program you wrote for Programming Challenge 13 so it also
              calculates and displays the amount of money Package A customers
              would save if they purchased Package B or C, and the amount of
              money Package B customers would save if they purchased Package C.
              If three would be no savings, no message should be printed.
    public class Internet3
         public static void main(String[] args)
              char ch, ch1;
              int hours;
              double monthlyBill, additionalBill, savings, total, saved;
              // Create a Scanner object for keyboard input.
              Scanner keyboard = new Scanner(System.in);
              // Get the letter of the package the user has purchased.
              System.out.println("Enter one of the letters of the package" +
                                       "you have purchased: A, B, or C?\nNote: "
                                       + "Please type in uppercase.");
              ch = keyboard.nextLine().charAt(0);
              // Create a DecimalFormat object.
              DecimalFormat formatter = new DecimalFormat("#0.00");
              // If the user typed A
              if (ch == 'A')
                   System.out.println("Have you purchased an additional package?" +
                                            " If so, enter the letter of the package." +
                                            " then press the enter key. If not, just "+
                                            "type N.\nNote: Please type in uppercase.");
                   ch1 = keyboard.nextLine().charAt(0);
                   if (ch1 == 'B' || ch1 == 'C')     // If the user typed B or C
                        System.out.println("Enter the number of hours " +
                                            "that you used in month.");
                        hours = keyboard.nextInt();
                        if (hours <= 10)               // If the user typed int less than or equal to 10
                             monthlyBill = 9.95;
                             System.out.println("Your original monthly bill is $" + monthlyBill);
                             savings = -4.00;
                             saved = monthlyBill + savings;
                             System.out.println("You saved $4.00 and the total monthly bill is $" +
                                                      formatter.format(saved));
                        else                              // If the user typed int more than 10
                             monthlyBill = 9.95;
                             total = monthlyBill + ((hours - 10)*2);
                             System.out.println("Your original monthly bill is $" + total);
                             savings = -4.00;
                             saved = total + savings;
                             System.out.println("You saved $4.00 and the total monthly bill is $" +
                                                      formatter.format(saved));
                   else if (ch1 == 'N')               // If the user typed N
                        System.out.println("Enter the number of hours " +
                                                 "that you used in month.");
                        hours = keyboard.nextInt();
                        if (hours <= 10)               // If the user typed int less than or equal to 10
                             monthlyBill = 9.95;
                             System.out.println("Your monthly bill is $" + monthlyBill);
                        else                              // If the user typed int more than 10
                             monthlyBill = 9.95;
                             total = monthlyBill + ((hours - 10)*2);
                             System.out.println("Your monthly bull is $" + formatter.format(total));
              else if (ch == 'B')                         // If the user typed B
                   System.out.println("Have you purchased an additional package?" +
                                            " If so, enter the letter of the package." +
                                            " then press the enter key. If not, just "+
                                            "type N.\nNote: Please type in uppercase.");
                   ch1 = keyboard.nextLine().charAt(0);
                   if (ch1 == 'C')                         // If the user typed C
                        System.out.println("Enter the number of hours " +
                                                 "that you used in month.");
                        hours = keyboard.nextInt();
                        if (hours <= 20)               // If the user typed int less than or equal to 20
                             monthlyBill = 13.95;
                             System.out.println("Your original monthly bill is $" + monthlyBill);
                             savings = -4.00;
                             saved = monthlyBill + savings;
                             System.out.println("Your saved $4.00 and the total monthly bill is $" +
                                                      formatter.format(saved));
                        else                              // If the user typed int more than 20
                             monthlyBill = 13.95;
                             total = monthlyBill + (hours - 20);
                             System.out.println("Your original monthly bill is $" + total);
                             savings = -4.00;
                             saved = total + savings;
                             System.out.println("You saved $4.00 and the total monthly bill is $" +
                                                      formatter.format(saved));
                   else if (ch1 == 'N')               // If the user typed N
                        System.out.println("Enter the number of hours " +
                                                 "that you used in month.");
                        hours = keyboard.nextInt();
                        if (hours <= 20)               // If the user typed int less than or equal to20
                             monthlyBill = 13.95;
                             System.out.println("Your monthly bill is $" + monthlyBill);
                        else                              // If the user typed int more than 20
                             monthlyBill = 13.95;
                             total = monthlyBill + (hours - 20);
                             System.out.println("Your monthly bill is $" + formatter.format(total));
              else if (ch == 'C')                         // If the user typed C
                   System.out.println("Enter the number of hours " +
                                            "that you used in mounth.");
                   hours = keyboard.nextInt();
                   if (hours > 0)                         // If the user typed int more than 0
                        monthlyBill = 19.95;
                        System.out.println("Your monthly bill is $" + monthlyBill);
              else                                        // If the user typed a character other than A, B, or C
                   System.out.println("That's not A, B, or C!");
    }

    #13:
              An Internet service provider has three different subscription
              packages for its customers:
              Package A:          For $9.95 per month 10 hours of access are provided.
                                  Additional hours are $2.00 per hour.
              Package B:          For $13.95 per month 20 hours of access are provided.
                                  Additional hours are $1.00 per hour.
              Package C:          For $19.95 per month unlimited access is provided.
              Write a program that calculates a customer's monthly bill. It should
              ask the user to enter the letter of the package the customer has
              purchased (A, B, or C) and the number of hours that were used. It should
              then display the total charges.
         #14:
              Modify the program you wrote for Programming Challenge 13 so it also
              calculates and displays the amount of money Package A customers
              would save if they purchased Package B or C, and the amount of
              money Package B customers would save if they purchased Package C.
              If three would be no savings, no message should be printed.
    import java.util.Scanner;               // Needed for Scanner class
    import java.text.DecimalFormat;          // Needed for DecimalFormat class
    public class Internet3
         public static void main(String[] args)
              char ch, ch1;
              int hours;
              double monthlyBill, additionalBill, savings, total, saved;
              // Create a Scanner object for keyboard input.
              Scanner keyboard = new Scanner(System.in);
              // Get the letter of the package the user has purchased.
              System.out.println("Enter one of the letters of the package" +
                                       "you have purchased: A, B, or C?\nNote: "
                                       + "Please type in uppercase.");
              ch = keyboard.nextLine().charAt(0);
              // Create a DecimalFormat object.
              DecimalFormat formatter = new DecimalFormat("#0.00");
              // If the user typed A
              if (ch == 'A')
                   System.out.println("Have you purchased an additional package?" +
                                            " If so, enter the letter of the package." +
                                            " then press the enter key. If not, just "+
                                            "type N.\nNote: Please type in uppercase.");
                   ch1 = keyboard.nextLine().charAt(0);
                   if (ch1 == 'B' || ch1 == 'C')     // If the user typed B or C
                        System.out.println("Enter the number of hours " +
                                            "that you used in month.");
                        hours = keyboard.nextInt();
                        if (hours <= 10)               // If the user typed int less than or equal to 10
                             monthlyBill = 9.95;
                             System.out.println("Your original monthly bill is $" + monthlyBill);
                             savings = -4.00;
                             saved = monthlyBill + savings;
                             System.out.println("You saved $4.00 and the total monthly bill is $" +
                                                      formatter.format(saved));
                        else                              // If the user typed int more than 10
                             monthlyBill = 9.95;
                             total = monthlyBill + ((hours - 10)*2);
                             System.out.println("Your original monthly bill is $" + total);
                             savings = -4.00;
                             saved = total + savings;
                             System.out.println("You saved $4.00 and the total monthly bill is $" +
                                                      formatter.format(saved));
                   else if (ch1 == 'N')               // If the user typed N
                        System.out.println("Enter the number of hours " +
                                                 "that you used in month.");
                        hours = keyboard.nextInt();
                        if (hours <= 10)               // If the user typed int less than or equal to 10
                             monthlyBill = 9.95;
                             System.out.println("Your monthly bill is $" + monthlyBill);
                        else                              // If the user typed int more than 10
                             monthlyBill = 9.95;
                             total = monthlyBill + ((hours - 10)*2);
                             System.out.println("Your monthly bull is $" + formatter.format(total));
              else if (ch == 'B')                         // If the user typed B
                   System.out.println("Have you purchased an additional package?" +
                                            " If so, enter the letter of the package." +
                                            " then press the enter key. If not, just "+
                                            "type N.\nNote: Please type in uppercase.");
                   ch1 = keyboard.nextLine().charAt(0);
                   if (ch1 == 'C')                         // If the user typed C
                        System.out.println("Enter the number of hours " +
                                                 "that you used in month.");
                        hours = keyboard.nextInt();
                        if (hours <= 20)               // If the user typed int less than or equal to 20
                             monthlyBill = 13.95;
                             System.out.println("Your original monthly bill is $" + monthlyBill);
                             savings = -4.00;
                             saved = monthlyBill + savings;
                             System.out.println("Your saved $4.00 and the total monthly bill is $" +
                                                      formatter.format(saved));
                        else                              // If the user typed int more than 20
                             monthlyBill = 13.95;
                             total = monthlyBill + (hours - 20);
                             System.out.println("Your original monthly bill is $" + total);
                             savings = -4.00;
                             saved = total + savings;
                             System.out.println("You saved $4.00 and the total monthly bill is $" +
                                                      formatter.format(saved));
                   else if (ch1 == 'N')               // If the user typed N
                        System.out.println("Enter the number of hours " +
                                                 "that you used in month.");
                        hours = keyboard.nextInt();
                        if (hours <= 20)               // If the user typed int less than or equal to20
                             monthlyBill = 13.95;
                             System.out.println("Your monthly bill is $" + monthlyBill);
                        else                              // If the user typed int more than 20
                             monthlyBill = 13.95;
                             total = monthlyBill + (hours - 20);
                             System.out.println("Your monthly bill is $" + formatter.format(total));
              else if (ch == 'C')                         // If the user typed C
                   System.out.println("Enter the number of hours " +
                                            "that you used in mounth.");
                   hours = keyboard.nextInt();
                   if (hours > 0)                         // If the user typed int more than 0
                        monthlyBill = 19.95;
                        System.out.println("Your monthly bill is $" + monthlyBill);
              else                                        // If the user typed a character other than A, B, or C
                   System.out.println("That's not A, B, or C!");
    }          

  • My ipod's screen went all fuzzy! Then it came on with black and white stripes/lines (vertical). Now it won't come on! What's wrong with my ipod? PLEASE HELP!

    PLEASE HELP!!!!

    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                                     

  • What is wrong with this code? please help

    Hello,
    Please pardon if you find my question too simple. I have the following
    code
    <form method=get action="page1.jsp">
    <input type=hidden name=Id value="<%= rs.getInt("id")%>" >
    <input type=hidden name=Title value="<%= rs.getString("title") %>" >
    <input type=hidden name=Price value="<%= rs.getDouble("price")%>" >
    <input type=submit name=operation value="Add">
    </form>
    i think they may be a problem here but i don't really know where .
    please could someone help me?
    Thank you.

    <%@page language = "java" import = "java.sql.*,java.lang.String"%>
    <html>
    <jsp:useBean id="userr" class="temp.Modifier" scope="session"/>
    <jsp:setProperty name="userr" property="*"/>
    <link href="../style/bleed.css" type="text/css" rel="stylesheet">
    <BODY text="#ffffff" link="#00CC66">
    <form name="form1" method="post" action="change.jsp">
    <table class=Mtable width="81%" border="0">
    <%
    try {
    userr.getConnect();
    String sql_stmt = null;
    String stu_no = request.getParameter( "stu_no");//get the value that inputed by the operator
    String subj_no = request.getParameter("subj_no");
    String teacher = request.getParameter("teacher");
    String term = request.getParameter("term");
    String year = request.getParameter("year");
    String stu_class = request.getParameter("class");
    String stu_name = request.getParameter("stu_name");
    String subj_name = request.getParameter("subj_name");
    if(!stu_no.equals("")){
    out.println("Stu_no = " + stu_no + ";<br>");
    if(!subj_no.equals("")){
    out.println("subj_no = " + subj_no + ";<br>");
    if(!teacher.equals("")){
    out.println("teacher = " + teacher + ";<br>");
    if(!term.equals("")){
    out.println("term = " + term + ";<br>");
    if(!year.equals("")){
    out.println("Year = " + year + ";<br>");
    if(!stu_class.equals("")){
    out.println("Class = " + stu_class + ";<br>");
    if(!stu_name.equals("")){
    out.println("Stu_name = " + stu_name + ";<br>");
    if(!subj_name.equals("")){
    out.println("subj_name = " + subj_name + ";<br>");
    out.println("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!<br>the role is :" + userr.getRole());
    %>
    <tr>
    <td width="11%"><div align="center"></div><font color="#3366ff">��  ��</font></div></td>
    <td width="11%"><div align="center"><font color="#3366ff">������</font></div></td>
    <td width="11%"><div align="center"><font color="#3366ff">��  ��</font></div></td>
    <td width="11%"><div align="center"><font color="#3366ff">��  ��</font></div></td>
    <td width="11%"><div align="center"><font color="#3366ff">��  ��</font></div></td>
    <td width="11%"><div align="center"><font color="#3366ff">��������</font></div></td>
    <td width="11%"><div align="center"><font color="#3366ff">��������</font></div></td>
    </tr>
    <%
    sql_stmt = userr.getSqlsentance_search(stu_no,subj_no,teacher, term, year, stu_class, stu_name, subj_name);
    ResultSet rrs = userr.stmt.executeQuery(sql_stmt);
    //check out how many content the resultset has
    int i = 1;
    for(i = 1;rrs.next();i++){
    userr.setArraylength(i);
    rrs.close();
    userr.stu_no =new int;//initialize these arrays
    userr.sub_no = new int[i];
    userr.score = new int[i];
    userr.year = new String[i];
    userr.teacher = new String[i];
    userr.term = new int[i];
    userr.status = new int[i];
    ResultSet rs = userr.stmt.executeQuery(sql_stmt);//start request the records from the DB
    for(i = 1 ;rs.next();i++){
    userr.setSub_no(i,rs.getInt(1));
    userr.setStu_no(i,rs.getInt(2));
    userr.setTerm(i,rs.getInt(3));
    userr.setYear(i,rs.getString(4));
    userr.setTeacher(i,rs.getString(5));
    userr.setStatus(i,rs.getInt(6));
    userr.setScore(i,rs.getInt(7));
    %>
    <tr>
    <td><font color="#3366ff"><%out.println(userr.getStu_no(i));%></font></td>
    <td><font color="#3366ff"><%out.println(userr.getRole());%></font></td>
    <%
    if(userr.getRole().equals("admin")){
    %>
    <td><input class=textfielda type="text" size = 11 name=<%out.println("score_changed"+i);%>size = 10 value = <%=userr.getScore(i)%>></td>
    <td><input class=textfielda type="text" size = 11 name=<%out.println("term_changed"+i);%>size = 10 value = <%=userr.getTerm(i)%>></td>
    <td><input class=textfielda type="text" size = 11 name=<%out.println("year_changed"+i);%>size = 10 value = <%=userr.getYear(i)%>></td>
    <td><input class=textfielda type="text" size = 11 name=<%out.println("status_changed"+i);%>size = 10 value = <%=userr.getStatus(i)%>></td>
    <td><input class=textfielda type="text" size = 11 name=<%out.println("teacher_changed"+i);%>size = 10 value = <%=userr.getTeacher(i)%>></td>
    </tr>
    <%
    }else if(userr.getRole().equals("opera")){
    if(userr.getScore(i) == 0){
    %>
    <td><input class=textfielda type="text" size = 11 name=<%out.println("score_changed"+i);%>size = 10 value = <%=userr.getScore(i)%>></td>
    <%
    }else{
    %>
    <td><%out.println(userr.getScore(i));%></td>
    <%
    %>
    <td><%out.println(userr.getTerm(i));%></td>
    <td><%out.println(userr.getYear(i));%> </td>
    <td><%out.println(userr.getStatus(i));%> </td>
    <td><%out.println(userr.getTeacher(i));%></td>
    </tr>
    <%
    }else{
    out.println("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!norole!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
    rs.close();
    if(!userr.getClose()){
    out.println("!!!!!!!!!!!!!!!!!!!DB close failed!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
    } catch (SQLException e) {
    e.printStackTrace();
    %>
    </table>
    <input class=botton name="button" type=submit value=" �� �� ">
    </form>
    </body>
    </html>
    I pardon you because I was worse when began, <%= %> instead of "<%= %>"

Maybe you are looking for