File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Stored proc not found...

 
Kingsley Mullers
Ranch Hand
Posts: 48
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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);
}
}
 
Sravan Kumar
Ranch Hand
Posts: 121
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try prefixing the strored procedure name with the owner name. for instance, if the owner is 'dbo', call it as dbo.getHR_PhoneBookEntryByUsername
 
Kingsley Mullers
Ranch Hand
Posts: 48
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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...
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic