Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
Java Tips
Java Tips Blog

Sponsored Links





Welcome to the Java Forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:

  • have access to post topics
  • communicate privately with other members (PM)
  • not see advertisements between posts
  • have the possibility to earn one of our surprises if you are an active member
  • access many other special features that will be introduced later.

Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 03-26-2008, 01:01 PM
Member
 
Join Date: Mar 2008
Posts: 13
geeta_ravikanti is on a distinguished road
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
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 04-22-2008, 03:39 AM
Member
 
Join Date: Apr 2008
Posts: 28
rico16135 is on a distinguished road
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.
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Executing stored procedures mew Database 2 04-22-2008 04:22 AM
Stored Procedures geeta_ravikanti Database 1 04-22-2008 03:34 AM
Calling stored procedures JavaForums Java Blogs 0 12-24-2007 01:30 PM
Stored Procedures with java Albert Database 4 06-08-2007 06:59 AM
stored procedures in Hibernate Alan Database 2 05-31-2007 05:49 PM


All times are GMT +3. The time now is 12:47 PM.


VBulletin, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org