Problem of accesing MS Acess database on Linux using Java

Below is my java code and errors found. Can anyone guide me tell me what is the problem and how to success access the .mdb file using Java on Linux?
import java.sql.*;
class readmdb
{      public static void main(String[] args)
{    String url;
Connection con;
Statement stmt;
try
{     Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
catch(java.lang.ClassNotFoundException e)
{    System.out.print("ClassNotFoundException: ");
System.out.println(e.getMessage());
try
{     con = DriverManager.getConnection("jdbc:odbc:DRIVER={/usr/local/lib/libmdbodbc.o.O}};DBQ=/home/powerstation/db/Database.mdb");
stmt = con.createStatement();
stmt.close();
con.close();
catch(SQLException ex)
{ System.err.println("SQLException: " + ex.getMessage());
Errors messages found after i executed the java code
shown above on linux platform.
Exception in thread "main"
java.lang.NullPointerException
at sun.jdbc.odbc.JdbcOdbcDriver.initialize(JdbcOdbcDriver.java:436)
at sun.jdbc.odbc.JdbcOdbcDriver.connect(JdbcOdbcDriver.java:153)
at java.sql.DriverManager.getConnection(DriverManager.java:512)
atjava.sql.DriverManager.getConnection(DriverManager.java:193)
at readmdb.main(readmdb.java:27)

jschell,
ODBC shell is the odbc.ini or odbcinst.ini? No.
The shell is something that you explicitly installed. Just like you installed Apache, or perl, or a C++ compiler, or even a CD driver.
If yes,
What is the difference between odbc.in and
odbcinst.ini? No idea. But on a windows box those are ini files that specify odbc info. I don't think ini files are going to help on linux.
Which of them will be execute when i
want to establish a connection using "jdbc:odbc:...."
in DriverManager.getConnection?I am rather sure that neither of them would 'execute'
>
Is it MS Access ODBC linux driver is the file like
libodbc.so, libmdbodbc.so, libmdbsql.so and so on?No idea, but I doubt it.
What makes you think that you even have a MS Access ODBC linux driver on your box?
Then, can u tell me which is MS Access ODBC linux
driver or what is the driver file name for MS Access
ODBC linux driver?Nope.
If you installed a MS Access ODBC linux driver, then the ODBC shell will know where it is.
And if you did install such a driver you should post the link where you got it here, because as far as I know, there is no such driver (nor is there one for MS SQL Server.)

Similar Messages

  • Open a PDF file in linux using java

    Hi..
    How can I open a PDF file in linux using java.
    I am able to open PDF in windows and mac using this code
    in Windows
    Runtime.getRuntime().exec("rundll32 url.dll,FileProtocolHandler " + path_of_PDF);
    in mac
    Runtime.getRuntime().exec("open " + path_of_PDF);
    But nothing is working with linux.
    Please help
    Thanks

    One thread is enough:
    http://forum.java.sun.com/thread.jspa?threadID=5267458

  • Open PDF file in linux using java

    Hi..
    How can I open a PDF file in linux using java.
    I am able to open PDF in windows and mac using this code
    in Windows
    Runtime.getRuntime().exec("rundll32 url.dll,FileProtocolHandler " + path_of_PDF);
    in mac
    Runtime.getRuntime().exec("open " + path_of_PDF);
    But nothing is working with linux.
    Please help
    Thanks

    appi wrote:
    Hi.. I found the JDIC binary files. There are different binaries for all the plateform. Is there any solution which is independent of plateform.Yes, and we already told you: Use JDK6, which has those libraries built into the standard class library.
    How can I use these binaries in my existing project. does it work, If I place them at same place where other .class files are kept.Read the documentation of the JDIC project. I'm sure they answer this question in their FAQ.

  • URGENT Creating database in Linux using RMAN dump of windows

    Hi Everyone,
    I'm having a problem in creating a database in Oracle Enterprise Linux using a database dump of Windows platform.
    I Have the following-
    -->RMAN Backup (for windows database)
    -->Archive log files.
    Using these i've to create the same database (clone) in linux.
    But when i'm try to do this ,everything goes fine except the datafile structures remain same as in windows( like C:\oracle\datafiles\system.dbf instead of /home/oracle/datafiles/system.dbf)
    And also i'm not able to restore the full database.
    Please suggest me the way to accomplish the task.
    Edited by: user8915599 on Jan 11, 2010 10:13 PM

    Hello
    You posted in the wrong forum, you'd better use one of the database forums : http://forums.oracle.com/forums/category.jspa?categoryID=18
    Anaway, regarding your datafile name strucyture you should look after db_file_name_convert in RMAN documentation. As for your other question, please be more precise (which version, what happens, etc).
    But again, post in the right forum and you'll get a ton of answers

  • How to run SQL script file on Linux using Java ?

    Hi,
    I need to execute .sql file using java. I used following approach for this.
    private void runScriptEvent(java.awt.event.ActionEvent evt) {                               
            String sqlOutput = "";
            String sqlPromptLines="";
            String currentFunctionName = "";
            if(con!=null){
                String userName = jTextField4.getText();
                String password = jPasswordField1.getText();
                String databaseName = jTextField3.getText();
                try {
                    String script_location = "";
                    ProcessBuilder processBuilder =null;
                    Process process = null;
                    //File file = new File("C:/ScriptFile");
                    File file = new File("./SQL_Script");
                    //File file = new File("E:\\install\\SQL_Script");
                    if(file.exists()){
                        File [] list_files= file.listFiles(new FileFilter() {
                                        public boolean accept(File f) {
                                        if (f.getName().toLowerCase().endsWith(".sql"))
                                        return true;
                                        return false;
                    int count = 0;
                        for (int i = 0; i<list_files.length;i++){
                            script_location = "@" + list_files.getAbsolutePath();//ORACLE
    //currentFunctionName = list_files[i].getName();
    StringTokenizer st = new StringTokenizer(list_files[i].getName(), ".");
    while(st.hasMoreTokens()) {
    currentFunctionName = st.nextToken();
    String extention= st.nextToken();
    System.out.println("Function Name = "+currentFunctionName + "\t Extention = " + extention);
    processBuilder = new ProcessBuilder("sqlplus",userName+"/"+password+"@"+databaseName, script_location); //ORACLE
    processBuilder.redirectErrorStream(true);
    process = processBuilder.start();
    BufferedReader in = new BufferedReader(new InputStreamReader(process.getInputStream()));
    String currentLine = null;
    while ((currentLine = in.readLine()) != null) {
    sqlPromptLines = " "+sqlPromptLines + currentLine +"\n";
    count ++;
    System.out.println(count+" " + currentLine);
    if(currentLine.equalsIgnoreCase("Function created.")){
    sqlOutput = "\n" sqlOutput currentFunctionName + " " currentLine"\n" ;
    break;
    }// end while
    in.close();
    process.destroy();
    }//end for
    }//end if file exists
    } catch (IOException e1) {
    jTextArea1.setText(e1.getMessage());
    System.out.println("Script Done");
    jTextArea1.append(sqlOutput);
    }// end id Connection is not null
    Above code working appropriate on Windows but not on Linux.
    is there any changes needed ?
    Regards,
    Ajay
    Edited by: Ajay Sharma on Nov 21, 2012 6:43 PM                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

    Hi gimbal2,
    about code
    jTextArea1.setText(e1.getMessage());I am using this code so that the user will be prompted with a message rather than stack trace.
    About the issue I am getting on linux i believe its because of following statement.
    processBuilder = new ProcessBuilder("sqlplus",userName+"/"+password+"@"+databaseName, script_location); //ORACLERegards,
    Ajay
    Edited by: Ajay Sharma on Nov 23, 2012 12:05 PM
    Edited by: Ajay Sharma on Nov 23, 2012 12:06 PM

  • Trouble creating a database in MySQL using java

    Hi all,
    I am trying to create a program that connects to MySQL and can create databases, tables etc. I can connect to MySQL using the program but I cannot create a database (however if i create the database with the command line i can create tables in the database).
    When I try to create a database i get the error
    com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Unknown database 'persondatabase'Here is the code:
    import java.sql.*;
    class Connect {
    public Connect() {
    public Connection connectToMySQL(String database_name) {
      Connection con = null;
      try {
       Class.forName("com.mysql.jdbc.Driver").newInstance();
       con = DriverManager.getConnection("jdbc:mysql:///persondatabase", "", "");
      catch(ClassNotFoundException e) { System.out.println(e); }
      catch(InstantiationException e) { System.out.println(e); }
      catch(SQLException e) { System.out.println(e); }
      finally {
       return con;
    public void createDatabase(String database_name) {
      Connection con = null;
      Statement stmt = null;
      try {
       con = connectToMySQL(null);  //connect to mysql but not to any one databases
       con.setAutoCommit(false);
       if(!con.isClosed())
        System.out.println("Connected to MySQL. Creating the Database " + database_name);
       String str = "CREATE DATABASE " + database_name;
       stmt = con.createStatement();
       stmt.executeUpdate(str);
       con.commit();
      catch (Exception e2) { }
      finally {
       try {
        stmt.close();
        con.close();
       }catch (Exception e3) { }
    public void createPersonDetailsTable(String database_name, String table_name) {
      Connection con = null;
      Statement stmt = null;
      try {
       con = connectToMySQL(database_name);
       con.setAutoCommit(false);
       if(!con.isClosed())
        System.out.println("Connected to " + database_name + " creating the table " + table_name);
       String str = "CREATE TABLE " + table_name + "(id INT NOT NULL AUTO_INCREMENT PRIMARY KEY, first_name VARCHAR(25), last_name VARCHAR(25), address VARCHAR(40), suburb VARCHAR(20), state VARCHAR(3), post_code INT(1), contact_number INT(10), email_address VARCHAR(40));";
       stmt = con.createStatement();
       stmt.executeUpdate(str);
       con.commit();
      catch (Exception e2) { System.out.println(e2); }
      finally {
       try {
        stmt.close();
        con.close();
       }catch (Exception e3) {  }
    }I am wondering if anyone can see where im going wrong? I am currently connecting with an anon account to MySQL.
    Here is the program I am using to test the above:
    class ConnectionTester {
    public ConnectionTester() {
      Connect s = new Connect();
      s.createDatabase("PersonDatabase");  //this throws the error
      //s.createPersonDetailsTable("PersonDatabase", "PersonDetails");
    public static void main(String[] arg) {
      ConnectionTester start = new ConnectionTester();
    }

    you should rethink whether you need to create a database using java. personally i think it's a bad idea. your database should exist and the schema should be ready to go when your app starts. why do you think you need to create one?
    %

  • Unable to print in linux using java 1.5

    Hi i could't able to print in linux system using java 1.5. Printer name is detecting.
    when i execute printDataTransferCompleted then printJobNoMoreEvents happening But print is not happening.
    here i attached the source.
    import javax.print.Doc;
    import javax.print.DocFlavor;
    import javax.print.DocPrintJob;
    import javax.print.PrintService;
    import javax.print.PrintServiceLookup;
    import javax.print.SimpleDoc;
    import javax.print.event.PrintJobEvent;
    import javax.print.event.PrintJobListener;
    public class HellowLinux {
         public static void main(String args[]){
              String printText = "The Java Tutorials are practical guides for programmers" ;
              DocFlavor byteFlavour = DocFlavor.BYTE_ARRAY.TEXT_PLAIN_UTF_8;
              Doc myDoc = new SimpleDoc(printText.getBytes(), byteFlavour, null);
              PrintService[] services = PrintServiceLookup.lookupPrintServices(byteFlavour, null);
              System.out.println("No of printer detected : "+services.length );
              for(int i = 0; i<services.length; i++){
                   System.out.println("Printer Name : "+services.getName());
              if(services.length > 0){
                   DocPrintJob myJob = services[0].createPrintJob();
                   myJob.addPrintJobListener(new PrintJobMonitor());
                   try{
                        myJob.print(myDoc, null);
                        System.out.println("Printed Successfully ... ");
                   }catch(Exception e){
                        System.out.println("Error : "+e.getMessage());
         private static class PrintJobMonitor implements PrintJobListener {
              public void printDataTransferCompleted(PrintJobEvent pje) {
                   // Called to notify the client that data has been successfully
              // transferred to the print service, and the client may free
              // local resources allocated for that data.
                   System.out.println("Data transfer Completed : "+pje.hashCode()
                             +"\n"+pje.getPrintEventType());
              public void printJobCanceled(PrintJobEvent pje) {
                   // Called to notify the client that the job was canceled
              // by a user or a program.
                   System.out.println("Cancelled : "+pje.hashCode()
                        +"\n Event Type "+pje.getPrintEventType());
              public void printJobCompleted(PrintJobEvent pje) {
                   // Called to notify the client that the job completed successfully.
                   System.out.println("Completed : "+pje.hashCode()
                             +"\n Event Type "+pje.getPrintEventType());
              public void printJobFailed(PrintJobEvent pje) {
                   // Called to notify the client that the job failed to complete
              // successfully and will have to be resubmitted.
                   System.out.println("Failed : "+pje.hashCode()
                             +"\n Event Type "+pje.getPrintEventType());
              public void printJobNoMoreEvents(PrintJobEvent pje) {
                   // Called to notify the client that no more events will be delivered.
                   System.out.println("No More Events : "+pje.hashCode()
                             +"\n Event Type "+pje.getPrintEventType());
              public void printJobRequiresAttention(PrintJobEvent pje) {
                   // Called to notify the client that an error has occurred that the
              // user might be able to fix.\
                   System.out.println("Requires Attention : "+pje.hashCode()
                             +"\n Event Type "+pje.getPrintEventType());
    Edited by: 936393 on May 24, 2012 12:08 AM

    Hi ,
    Go to Help menu >> update
    it will update your application to 13.1
    then go to  Editor 's Edit menu >> Preferences and click on Reset Preference on next launch .
    after that relaunch your application..
    Refer article for the same:
    https://helpx.adobe.com/photoshop-elements/kb/elements-printer-issue-incompatible-error.ht ml

  • How to get free disk space in linux   Using JAVA program ?

    Hi,
    I am new to such adavance topics.. like JNI
    I have to check linux system free disk space , if space is more than 80% it should email to user.
    But how to check that Using Java program ??
    can u give me one sample example ? i will do it if u can do some for me
    thanks
    give me possible solutions...

    Using the Runtime class you can execute any linux command. Check it out.

  • Executing WINWORD from both Windows and linux using Java

    Dear All,
    I have a problem when trying to use Runtime class to execute a winword document. My code is as follows.
    Runtime r= Runtime.getRuntime();
    try{
    r.exec("rundll32"+" "+"url.dll,FileProtocolHandler"+" "+"WINWORD"+ " "+"file://C://welkom.doc");
    catch(Exception ex){
    System.out.println("Unable to open the doc file:"+ex);
    When I execute this swing application with the above, the program is unable to open the specific file. And it says "Problem with the short cut, unable to open the file". When I run the program without the file name, it opens a new doc file.
    Attn: what I want to do here is I need to open the winword file from both windows and linux. So I cannot use the relative path of the WINWORD.exe file.
    Can anyone help me?
    Thanks in advance.
    Regards,
    Bala

    If you take a look at the api, there's an exec(String[]) method. This is the one you should use when calling a command with multiple parameters.
    so something like...
    String[] cmd = new String[] {"rundll32", "url.dll,FileProtocolHandler", "WINWORD", "file://C://welkom.doc"}
    r.exec(cmd);

  • Archiving File on Shared Folder in Linux using java code

    Hi All,
    I have a requirement wherein I have to ftp a file (Feed.txt) from windows FTP server to Linux machine1 and archive the same file (with timestamp suffixed on file name like Feed.txt_22April) on Linux Machine2. I am
    trying to achieve this through java code. I am able to ftp the file(Feed.txt) from windows ftp server to Linux machine1 /opt/ftproot directory and archiving the same file under /opt/ftproot/archive directory of Linux
    Machine1 with timestamp suffixed on file name.
    My archiving requirement is still not achieved. So, for that I created a shared folder “/temp/shared” on Linux Machine2 and mounted the /temp/shared folder of Linux Machine2 on /opt/ftproot/archive folder of
    Linux Machine1 using following command:
    # mount LinuxMachine2: /temp/shared /opt/ftproot/archive
    Note: I have given full permission on both the folders.
    Logically, archiving the Feed.txt with timestamp in it name under /opt/ftproot/archive folder should create the file in /temp/shared folder of Linux Machine2. But instead of archiving the file on
    /opt/ftproot/archive folder, it archive the file on /opt/ftproot folder.
    In my java code, I have specified copyDir as “/opt/ftproot” and archiveDir as /opt/ftproot/archive”.
    The code is being run from Linux Machine1 as a schedule task.
    Please help.
    PFB the code snippet:
    package com.ftp;
    import com.thortech.xl.scheduler.tasks.SchedulerBaseTask;
    import org.apache.commons.net.ftp.*;
    import java.io.File;
    import java.io.FileInputStream;
    import java.io.FileOutputStream;
    import java.io.IOException;
    import java.io.InputStream;
    import java.io.OutputStream;
    import java.text.DateFormat;
    import java.text.SimpleDateFormat;
    import java.util.Calendar;
    import java.util.Date;
    public class FTPService extends SchedulerBaseTask {
         private static String targetDir="";
         private static String archiveDir="";
    public void init() {
    public void execute() {
    try {
    String server = "Machine1
    String username = "username";
    String password = "password";
    String sourceDir = "C:\\Inetpub\\ftproot\\temp.txt";
    //String archiveDir = "/home/ftproot1";
    targetDir = getAttribute("Target Directory");
    FTPClient ftp = new FTPClient();
    * Connect to the server
    ftp.connect(server);
    ftp.login(username, password);
    System.out.println("Connected to " + server + ".");
    String[] names = ftp.listNames();
    for (String name : names) {
    System.out.println("Name = " + name);
    * Get all file names that are present in the current working directory
    FTPFile[] files = ftp.listFiles();
    String fileName = "";
    for (int i = 0; i < files.length; i++) {
    if (files.isFile()) {
    System.out.println("\t" + files[i].getName());
    File file = new File(targetDir + File.separator +
    files[i].getName());
    FileOutputStream fos = new FileOutputStream(file);
    * Copy the file to target system
    ftp.retrieveFile(files[i].getName(), fos);
    fos.close();
    fileName = files[i].getName();
    ftp.logout();
    ftp.disconnect();
    System.out.println("End of FTP....");
    System.out.println("Calling fileCopy()");
    System.out.println("Target Directory"+targetDir);
    fileCopy(fileName,targetDir);
    } catch (Exception e) {
    e.printStackTrace();
    public static String getDate() {
    String sdate = "";
    try {
         System.out.println("Inside getDate()");
    Calendar date = Calendar.getInstance();
    SimpleDateFormat formatter = new SimpleDateFormat(
    "yyyy-MM-dd HH:mm:ss.0");
    sdate = formatter.format(date.getTime());
    } catch (Exception e) {
    return sdate;
    public void moveFile(String t) {
         try{
         System.out.println("inside moveFile");
    System.out.println("Moving Files");
    File fro = new File(t);
    archiveDir = getAttribute("Archive Directory");
    System.out.println("Archiving Directory"+archiveDir);
    File to = new File(archiveDir);
    boolean archived = fro.renameTo(new File(to, fro.getName()));
    if (archived) {
    System.out.println("FileArchived");
              /*String cmd="mv" +" "+t +" "+ "/home/ftproot/archive";
              System.out.println("Archive Directory"+archiveDir);
              System.out.println("Move Command"+cmd);
              Process SshProc =      (Runtime.getRuntime()).exec(cmd);
    } catch (Exception e) {
    e.printStackTrace();
    public void fileCopy(String filename,String Directory) {
         try{
         //String ifile="/home/ftproot/sunny.txt";
              String ifile=targetDir+"/"+filename;
         String ofile=ifile+"_"+getDate();
         File f1 = new File(ifile);
         File f2 = new File(ofile);
         InputStream in = new FileInputStream(f1);
         //For Append the file.
    //      OutputStream out = new FileOutputStream(f2,true);
         //For Overwrite the file.
         OutputStream out = new FileOutputStream(f2);
         byte[] buf = new byte[1024];
         int len;
         while ((len = in.read(buf)) > 0){
         out.write(buf, 0, len);
         in.close();
         out.close();
         System.out.println("File copied.");
         moveFile(ofile);
         }catch(Exception e)
         System.out.println("File copied."+e);
    Cheers,
    Sunny

    sunnyajmera wrote:
    Please help.If it was me....
    - You are connecting to a ftp server. I am guessing you didn't write that.
    - Get a flexible ftp client, there are many but make sure it shows you the ftp result codes.
    - Figure out how and if the ftp server will do what you want.
    If it does do what you want then ftp client will let you do the same thing.
    If that ftp server doesn't allow you to do it then you must do one of the following
    - Find a different server
    - Change the requirements
    - Find a way to impose the requirements using a tool in addition to ftp like some command executed through telnet.

  • How to create a ms-access database at runtime using java

    hi, this is ravi kiran,
    i have a situation where i need to create a new ms-access database with one table in it at runtime(when user clicks on some button).
    i have been searching many sites to know how to do this in java, but i didnot find any thing useful.
    plz tell me how to do this in java.
    plz help me, its urgent
    thanx in advance.

    Here's how I did it. Research does help, but sometimes looking at others code does too... You do have to have a dummy file that you made with access though. You can't just make a file file.mdb (it will be corrupt)
         public void createDatabase(String database) throws SQLException{
              try{
                   // This file needs to have been created with MS Access
                   File dbfile = new File(this.dataBaseDir + "dummy.mdb");
                   // This is the new database file being made
                   File newFile = new File(this.dataBaseDir + database + ".mdb");
                   // Copy all bytes from dummy file to new DB file.
                   FileInputStream instream = new FileInputStream(dbfile);
                   FileOutputStream ostream = new FileOutputStream(newFile);
                   int numBytes = instream.available();
                   byte inBytes[] = new byte[numBytes];
                   instream.read(inBytes, 0, numBytes);
                   ostream.write(inBytes, 0, numBytes);
              catch(FileNotFoundException e) { e.printStackTrace();}
              catch(IOException e) { e.printStackTrace();}
              if(DEBUG) System.out.println("creating the " + database + " database");
         }

  • How to change locale of keyboard in linux using java.

    In my application I have a JTextArea . In that field i have to call my language dependent keyboard. How to do this?. I tried with InputContext ipt = InputContext.getInstance();
    ipt.selectInputMethod(new Locale("en", "US"))But it is working in windows, but not in linux.

    If any one have experience in this, please respond...

  • Problems trying to retrieve data from R/3 using Java - RecordSetWrapper

    Hello everyone!
    I am having problems retrieveing a result from r/3 using Connector Framework API. An ABAP consultant has created a ABAP program which returns an employee based on his or her personal number as an input.
    <b>When i run the AbstractPortalComponent i get the following:
    <u>RS2: com.sapportals.connectors.SAPCFConnector.execution.structures.RecordSetWrapper@24648563</u></b>
    My code is as follows:
    package com.sap.test;
    import java.util.ArrayList;
    import java.util.Iterator;
    import javax.resource.cci.MappedRecord;
    import javax.resource.cci.RecordFactory;
    import com.sap.security.api.IUser;
    import com.sapportals.connector.connection.IConnection;
    import com.sapportals.connector.execution.functions.IInteraction;
    import com.sapportals.connector.execution.functions.IInteractionSpec;
    import com.sapportals.connector.execution.structures.IRecordSet;
    import com.sapportals.connector.execution.structures.IStructureFactory;
    import com.sapportals.connector.metadata.functions.IFunction;
    import com.sapportals.portal.ivs.cg.ConnectionProperties;
    import com.sapportals.portal.ivs.cg.IConnectorGatewayService;
    import com.sapportals.portal.ivs.cg.IConnectorService;
    import com.sapportals.portal.prt.component.*;
    import com.sapportals.portal.prt.runtime.PortalRuntime;
    public class Search extends AbstractPortalComponent{
         String sapSystem = "*****";
         public void doContent(IPortalComponentRequest request, IPortalComponentResponse response){
              IConnection con = null;
              ConnectionProperties conprop = null;
              ConnectionProperties cp = null;
              try{
                   Object connectorService = PortalRuntime.getRuntimeResources().getService(IConnectorService.KEY);
                   IConnectorGatewayService cgService = (IConnectorGatewayService) connectorService;
                   cp = new ConnectionProperties(request.getLocale(),request.getUser());
                   if(cgService == null){
                        response.write("Error in getting Connector Gateway Service <br>");
                   try{
                        con = cgService.getConnection(sapSystem, cp);
                        IInteraction ix = con.createInteractionEx();
                        IInteractionSpec ixSpec = ix.getInteractionSpec();
                        ixSpec.setPropertyValue("Name", "Test_RFC");
                        RecordFactory rf = ix.getRecordFactory();
                        MappedRecord importParams = rf.createMappedRecord("INPUT");
                        IFunction function = con.getFunctionsMetaData().getFunction("Test_RFC");
                        IStructureFactory structureFactory = ix.retrieveStructureFactory();
                        IRecordSet table = (IRecordSet) structureFactory.getStructure(function.getParameter("I_PA0002").getStructure());
                        importParams.put("PERNR", "123456");
                        MappedRecord output = (MappedRecord) ix.execute(ixSpec,importParams);
                        Object rs = null;
                        try{
                             Object result = output.get("I_PA0002");
                             if(result == null){
                                  rs = new String ("Error");
                                  response.write("RS1: " +rs+ "<BR>");
                             else
                                  if(result instanceof IRecordSet){
                                       rs = (IRecordSet) result;
                                       response.write("RS2: " +rs+ "<BR>");
                                  else{
                                       response.write("RS3: " +rs+ "<BR>");
                        catch(Exception e){
                             response.write("Error " + e.getMessage()+ "<BR>");
                   catch(Exception e){
                        response.write("Connection to SAP system failed <br>");
                   if(con == null){
                        response.write("Connection is null <br>");
                   else{
                        response.write("Connection succsesful<BR>");
              catch(Exception e){
                   response.write("Exception occured<BR>");
              try{
                   con.close();
                   response.write("Connection closed<br>");
              catch(Exception e){
                   response.write("Could NOT close connection<BR>");
    The result should be all data stored on the person which I search for, but instead i get the following result:
    <b>
    RS2: com.sapportals.connectors.SAPCFConnector.execution.structures.RecordSetWrapper@24648563</b>
    I am really stuck and do not know how to solve the problem. I appreciate any help or sample (or just some answers...)
    Thanks in Advance.
    Best Regards,
    Ola Aarthun

    Hi,
    From your code you are just displaying the object rs. You have to handle the display of each record the way you want it(as a table).
    You can find a sample code how to build a table from the result object at the following link
    https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/bfb1ba90-0201-0010-5e97-bd6a8f5022dc
    Regards,
    Padmaja

  • Database access design using java bean

    Hi,
    I am writing a JSP/servlet/Javabean based app. using MVC architecture.The database related logic is in java beans.
    I want a generalized class/bean that can form a connection , execute the passed query and return the results.Does any one has any URLs or sample code to explain how to do this using introspection?
    I would greatly appreciate any help as this design is very crucial for our application.
    Thanks -
    k

    Please check the Cameleon Open Source project at http://www.must.de/cameleon.html if ti fits your needs.

  • Cannot recognise any sound devices in Linux using Java sound!

    Hi there - I'm new to Java sound, and can't even get my foot in the door on my Linux system. Even thought my speakers and microphone are fully functional on my system (I can record, playback, etc. using other programs) I cannot get Java to find the microphone, speaker, anything. I've tried calling "AudioSystem.isLineSupported(Port.Info.MICROPHONE)", which returns false, as with all the other Port.Info.... objects.
    I'm sure there are no programs using my audio devices (used lsof | grep snd and lsof | grep dsp, then killed the only program that had anything open) and I've tried running my Java program as the super-user too, but to no avail.
    One thing I CAN do is get sound from /dev/dsp - I can put this into a byte array and play it back later, but I don't know how to find out what sort of codec it uses, how to merge it with Java sound, or anything like that.
    Any help would be much appreciated!
    If it makes any difference, I'm using Xubuntu 8.10, and I normally don't use a microphone or flashy surround-sound speakers, so I've not touched the sound system since I installed Linux.

    Ports are tricky...and by tricky, I don't mean complicated so much as a pain.
    Try using Line.Info objects instead of Port.Info objects and see if you can get any lines.

Maybe you are looking for

  • Populating the data

    populating the data to the data base table .... which i created using only reports ... can any body tell the approach ....... if possible coding also plz help me out .. but using only general reports ..

  • Authorize in JSF pages

    Hello, I am new in JSF and I am wondering how to make following issue. I would like to make a some authorize functionality on my web application. My imagine is following. At the begining of each page, will be control if user is already logged or not.

  • Loupe Displays a Different Version on Second Monitor

    I use Aperture on MBP with a CRT Monitor. I have noticed when I use the loupe on the second monitor the Loupe shows a darker version of the image. Without loupe the image looks similar to the laptop display. The CRT is calibrated and set as the Defau

  • Viewing .mod files on MacBook Pro

    Recently switched to a Mac from PC and trying to open digital home videos that I took on a JVC Everio. They are .mod files and will not open on my Mac. Is there a special converter or something I need to view these files? I hate to think the last 2 y

  • How to shows result as Alias name.

    Dear All, I am having following query and output, in that inside query showing one record check another query, that result i want to show as Alias, Can we show result as alias ?           select SPL.speciality_description,Emp.FIRSTNAME,DT.full_date