on 06-19-2008 12:00 PM
Hi,
When i tried the following code it returns no of repositories comes under the server.
public class Repositories {
public static void main(String[] args) {
String tag = "SSSS";
ConnectionPool connections = null;
try {
connections = ConnectionPoolFactory.getInstance(tag);
} catch (ConnectionException e) {
e.printStackTrace();
return;
}
GetMountedRepositoryListCommand gr = new GetMountedRepositoryListCommand(connections);
try
{
gr.execute();
}
catch(Exception e)
{
}
MountedRepository n[] = gr.getRepositories();
MountedRepository ns;
String repositoryName="";
int repno=0;
for(int i=0;i<n.length;i++)
{
System.out.println(n<i>.getName());
}
}
I passed one of the repository name returned by above code to RepositoryIdentifier reposId = new RepositoryIdentifier("rep1", "SSSS", DBMSType.ORACLE);. But it returned the Exception com.sap.mdm.commands.CommandException: com.sap.mdm.internal.protocol.manual.ServerException: The specified MDM repository was not found on the server
at com.sap.mdm.commands.CreateRepositorySessionCommand.execute(CreateRepositorySessionCommand.java:79) when encounter the line sessionCommand.setRepositoryIdentifier(reposId );
sessionCommand.execute();
But That repository existing on that server.
Please tell me what is the solution for this?
Thanks.
Hi,
Check the below code. In order to get the running repositories there is no need to create the Session. Now if you want to deal with the repository data then you have to create the User Session and if you want to modify the structure of the repository then Repository Session is to be created.
public class Test
{
public static ConnectionAccessor simpleConnection;
public static String connection = "MDM_SERVER";
public static void main(String[] args)
{
try
{
simpleConnection = SimpleConnectionFactory.getInstance(connection);
}
catch(Exception ex)
{
System.out.println(ex);
}
GetRunningRepositoryListCommand getRunningRepCmd = new GetRunningRepositoryListCommand(simpleConnection);
try
{
getRunningRepCmd.execute();
}
catch(Exception ex)
{
System.out.println(ex);
}
RepositoryIdentifier[] reposIds = getRunningRepCmd.getRepositories();
for (int i = 0; i < reposIds.length; i++)
{
System.out.println(reposIds<i>.getName());
}
}
}
REWARD if found useful
Regards,
Jitesh Talreja
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
I am getting the same error, but I not using custom development. I configured uwl for standard repositories. but not able to see the task information in uwl iview. I am getting the error in log files like com.sap.mdm.internal.protocol.manual.ServerException: The specified MDM repository was not found on the server#. I have checked the my MDM_JAVA_API 5.50 SP6 (1000.5.50.6.0.20071025122249) and the MDM server version is MDMServer64Install_Ver5.5.60.67. Could you please suggest me how to proceed for this.
Regards,
Mahi
Hi,
Check the code given below. Its working fine at my end. Your repositories should be mounted and in running state. Try to pass the IP address of the MDM Server instead of name.
public class repositories
{
public static String connection = "MDM_SERVER";
public static void main (String args[])throws CommandException, ConnectionException
{
ConnectionPool connection1=ConnectionPoolFactory.getInstance(connection);
GetMountedRepositoryListCommand mount=new GetMountedRepositoryListCommand(connection1);
try
{
mount.execute();
}
catch(Exception e)
{
}
MountedRepository[] repos=mount.getRepositories();
System.out.print(repos.length);
for(int i=0;i<repos.length;i++)
{
System.out.print(repos<i>.getName());
}
}
}
Please Reward if it is useful
Regards,
Jitesh Talreja
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
Thanks Jitesh. I passed one of running repository identifier returned by the class GetRunningRepositoryListCommand. Now this code can identify the repository, but when i run the program it is returning the exception com.sap.mdm.commands.CommandException: com.sap.mdm.internal.protocol.manual.ServerException: File failed a crc check
at com.sap.mdm.commands.AuthenticateRepositorySessionCommand.execute(AuthenticateRepositorySessionCommand.java:94) when execute the line authCommand.execute();
in the code.
But that username and password are correct. Is there any other way to authenticate?
public class NewMain {
public static void main(String[] args) {
String tag = "Ipaddress";
ConnectionPool connections = null;
try {
connections = ConnectionPoolFactory.getInstance(tag);
} catch (ConnectionException e) {
e.printStackTrace();
return;
}
System.out.print(connections.getHostname());
// specify the repository to use
// alternatively, a repository identifier can be obtain from the GetMountedRepositoryListCommand
GetRunningRepositoryListCommand grun = new GetRunningRepositoryListCommand(connections);try
{
gr.execute();
grun.execute();
}
catch(Exception e)
{
}
RepositoryIdentifier rid[] = grun.getRepositories();
RepositoryIdentifier reposId = new RepositoryIdentifier("rep1", "ipaddr", DBMSType.ORACLE);
for(int rcount=0;rcount<rid.length;rcount++)
{
System.out.println("run "rid[rcount]" "rid[rcount].getDBMS()" "rid[rcount].getDBMSType()" ");
if(rid[rcount].toString().equals("rep1"))
{
reposId=rid[rcount];
}
}
MountedRepository n[] = gr.getRepositories();
MountedRepository ns;
String repositoryName="";
int repno=0;
String dbmsName = "ipaddress";
// create a repository session
CreateRepositorySessionCommand sessionCommand = new CreateRepositorySessionCommand(connections);
System.out.println(reposId);
sessionCommand.setRepositoryIdentifier(reposId );
try {
sessionCommand.execute();
} catch (CommandException e) {
e.printStackTrace();
return;
}
String sessionId = sessionCommand.getRepositorySession();
System.out.println("After ionId");
// authenticate the repository session
String userName = "java";
String userPassword = "mdm";
AuthenticateRepositorySessionCommand authCommand = new AuthenticateRepositorySessionCommand(connections);
authCommand.setSession(sessionId);
authCommand.setUserName(userName);
authCommand.setUserPassword(userPassword);
try {
authCommand.execute();} catch (CommandException e) {
e.printStackTrace();
return;
}
// retrieve the list of tables and pick the main table
GetTableListCommand tableListCommand = new GetTableListCommand(connections);
tableListCommand.setSession(sessionId);
try {
tableListCommand.execute();
} catch (CommandException e) {
e.printStackTrace();
return;
}
TableProperties mainTable = null;
TableProperties[] tables = tableListCommand.getTables();
for (int i = 0; i < tables.length; i++) {
if (tables<i>.getType() == TableProperties.MAIN)
mainTable = tables<i>;
}
// retrieve the list of fields from the main table
// this is useful for resolving conflicting field names the new field might create
GetFieldListCommand getFieldListCommand = new GetFieldListCommand(connections);
getFieldListCommand.setSession(sessionId);
getFieldListCommand.setTableId(mainTable.getId());
try {
getFieldListCommand.execute();
} catch (CommandException e) {
e.printStackTrace();
return;
}
// TODO code application logic here
}
}
Thanks in advance.
User | Count |
---|---|
87 | |
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.