on 03-12-2008 4:33 AM
Hi All
i am using SQL Server 2005 as a backend for webservices, i want to select the data based on the user input in where condition,
SELECT [NO]
,[NAME]
,[PAGE_COUNT]
FROM [DS].[DB].[tablename]
where [NO]=???
Ex: i will pass the NO to the webservice to get the respective data from SQL,but i am not sure what operand to give in where condition,does anybody have idea on this
Thanks and Regards
Chaitanya.A
Hi,
Make use of prepared statements
http://java.sun.com/docs/books/tutorial/jdbc/basics/prepared.html
Regards
Ayyapparaj
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Sudhir / Ayyapparaj
The query which i posted is the same which i am using in SQL ( along with square brackets)
i am tryting to execute the same query using the options provided by you in SQL 2005 ,even then i am not getting any prompt to enter input.
first i want to test in SQL and then implement in webdynpro.
Thanks
Chaitanya.A
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
HI
public String getEmployeeName(String employeeNumber)
{
// TODO : Implement
String name = new String();
String exception = new String();
try
{
InitialContext initialContext = new InitialContext();
DataSource dataSource =(DataSource) initialContext.lookup("jdbc/XXXX");
java.sql.Connection connection = dataSource.getConnection();
PreparedStatement stmt =connection.prepareStatement("SELECT [NAME]FROM [XXX].[ASDF].[ABCD] where [NO]=?");
stmt.setString(1,employeeNumber);
ResultSet result = stmt.executeQuery();
while (result.next())
{
name = result.getString("Name");
}
connection.close();
return name;
}
catch (Exception e)
{
exception = "Exception";
return exception;
}
}
i used the above function to achieve my requirement
Thanks
Chaitanya.A
Hi,
PreparedStatement stmt = null;
String query="SELECT [NO]
,[NAME]
,[PAGE_COUNT]
FROM [DS].[DB].[tablename]
where [NO]=?";
stmt = con.prepareStatement(QUERY);
stmt.setInt(1, no);
rs = stmt.executeQuery();
where "no" is the number which you get from webservive.
Regards,
Sudhir
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
88 | |
23 | |
11 | |
9 | |
8 | |
5 | |
5 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.