Results 1 to 2 of 2
  1. #1
    Join Date
    Mar 2008
    Posts
    13
    Rep Power
    0

    Red face unable to exceute stored procedures

    import java.sql.*;


    public class CrTable
    {

    //Add an employee to the database.
    public static void addEmp(int emp_id, String emp_f_name,
    String emp_l_name,float emp_salary) {

    System.out.println("Creating new employee...");

    try{
    Class.forName("com.microsoft.sqlserver.jdbc.SQLSer verDriver");

    Connection con=DriverManager.getConnection("jdbc:sqlserver://localhost:1433;databaseName=master;user=sa;passwor d=remora");

    System.out.println("connceted----->"+con.getClass());

    String sql =
    "INSERT INTO emp " +
    "(emp_id,emp_f_name,emp_l_name,emp_salary)" +
    "VALUES(?,?,?,?)";
    PreparedStatement pstmt = con.prepareStatement(sql);
    pstmt.setInt(1,emp_id);
    pstmt.setString(2,emp_f_name);
    pstmt.setString(3,emp_l_name);
    pstmt.setFloat(4,emp_salary);
    pstmt.executeUpdate();
    pstmt.close();

    }
    catch(Exception e)
    {
    System.err.println("ERROR! Adding Employee: "
    + e.getMessage());

    }

    }
    }



    When i am running the above program I am getting the out put like this

    The Selection Doesnot support Runmode
    what is the meaning of that error
    how can i resolve this problem
    any one can help solving this problem

    Geeta

  2. #2
    rico16135 is offline Member
    Join Date
    Apr 2008
    Posts
    28
    Rep Power
    0

    Default

    first of all: JDBC is recommending that the DataSource interface should be used to create database connection objects instead of using the DriverManager class.

    check here: Implementations of the DataSource Interface

    Second put your code in code blocks, its too hard to read.
    Third pstmt.setInt(1,emp_id); You seem to be telling it what column to insert to twice. 1 is the order, emp_id is the column name. Change that column name to what you actually want to enter into that field.

Similar Threads

  1. Executing stored procedures
    By mew in forum JDBC
    Replies: 3
    Last Post: 08-20-2008, 05:47 PM
  2. Stored Procedures
    By geeta_ravikanti in forum JDBC
    Replies: 1
    Last Post: 04-22-2008, 02:34 AM
  3. Stored Procedures with java
    By Albert in forum JDBC
    Replies: 4
    Last Post: 06-08-2007, 05:59 AM
  4. stored procedures in Hibernate
    By Alan in forum JDBC
    Replies: 2
    Last Post: 05-31-2007, 04:49 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •