Forums Register Login

Stored proc not found...

+Pie Number of slices to send: Send
Hi there,

I�ve finally managed to connect to SQL Server but the problem is that the stored procedure is not found whereas it does exists, is there anything that I might have omitted that�s causing this type of error, I�ve specified the full path but no success,
---------------------------------------------------------------------------
my code looks like this..

import java.sql.*;
import com.microsoft.jdbc.sqlserver.*;
import com.microsoft.jdbc.*;
import java.sql.CallableStatement;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.Statement;
/**
* Microsoft SQL Server JDBC
*/
public class PhoneBookDetails {
// Get connection
// DriverManager.registerDriver(new com.microsoft.jdbc.sqlserver.SQLServerDriver());
public Connection getConnection(){
Connection connection=null;
try{
String driverName = "com.microsoft.jdbc.sqlserver.SQLServerDriver";
Class.forName(driverName);
String username="fido";
String password="odif";
String databasename="RSAPORTAL";
String url="jdbc:microsoft:sqlserver://SERVERNAME:0000;
databasename= data_base_name;username=username;password=password";
connection=DriverManager.getConnection(url,username,password);

}catch(ClassNotFoundException e)
{
System.out.println("ClassNotFoundException");

}catch(SQLException e){
System.out.println("Exception" +e);
}
return connection;
}

public String getPhoneBookDetails(Connection connection,String Username)
{
String details="";
try{
CallableStatement callableStatement =connection.prepareCall("{call getHR_PhoneBookEntryByUsername ?}");
callableStatement.setString(1,Username);
ResultSet resultSet = callableStatement.executeQuery();
if(resultSet.next())
{
System.out.println("usernameDetail 1 " + resultSet.getString(2));
System.out.println("usernameDetail 2 " + resultSet.getString(3));
System.out.println("usernameDetail 3 " + resultSet.getString(4));
System.out.println("usernameDetail 4 " + resultSet.getString(5));
System.out.println("usernameDetail 5 " + resultSet.getString(6));
System.out.println("usernameDetail 6 " + resultSet.getString(7));
System.out.println("usernameDetail 7 " + resultSet.getString(8));
System.out.println("usernameDetail 8 " + resultSet.getString(9));
System.out.println("usernameDetail 9 " + resultSet.getString(10));
System.out.println("usernameDetail 10 " + resultSet.getString(11));
System.out.println("usernameDetail 11 " + resultSet.getString(12));
System.out.println("usernameDetail 12 " + resultSet.getString(13));
System.out.println("usernameDetail 13 " + resultSet.getString(14));
System.out.println("usernameDetail 14 " + resultSet.getString(15));

}
}catch(Exception e){
System.out.println("Exception" +e);
}
return details;
}
public void closeConnection(Connection cn){

try{

if (cn != null)
cn.close();
cn=null;
}catch(Exception e){
e.printStackTrace();
}
}
public static void main (String args[]) throws Exception
{
PhoneBookDetails test = new PhoneBookDetails();
Connection c=test.getConnection();

if(c==null)
{
System.out.println("Connection is null...");
}else
{
String x =test.getPhoneBookDetails(c, "Mwelas_m");
System.out.println("Connection is successful...!!!");
}
test.closeConnection(c);
}
}
+Pie Number of slices to send: Send
Try prefixing the strored procedure name with the owner name. for instance, if the owner is 'dbo', call it as dbo.getHR_PhoneBookEntryByUsername
+Pie Number of slices to send: Send
thanks for the response, i've tried that, cos the store proc above it has dbo, but this one i'm calling has fido in front of it but still no luck...
BWA HA HA HA HA HA HA! Tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 1284 times.
Similar Threads
Poblem with Callable Statement
JDBC Newbie
need java logic
Connection Through JDBC
setAutoCommit(autocommit);
More...

All times above are in ranch (not your local) time.
The current ranch time is
Apr 16, 2024 09:14:46.