FileMaker as the data source via JDBC

Discussion in 'Mac Programming' started by Howiieque, May 10, 2009.

  1. Howiieque macrumors regular

    Joined:
    Feb 1, 2009
    #1
    Hi.
    I want to use FileMaker database as the data source locally. Must I have the server edition?
    I have installed JDBC Client Driver, but java can found it.
    Where should I install it?
    Or my code has some problems?
    here is the code:
    Code:
    import java.sql.*;
    public class testDrive {
    	public static void main(String args[]) {
    		
    		// register the JDBC client driver
    		try {
    			Driver d=(Driver)Class.forName("com.ddtek.jdbc.sequelink.SequeLinkDriver").newInstance();
    			//Class.forName("com.ddtek.jdbc.sequelink.SequeLinkDriver");
    		} catch(Exception e) {
    			System.out.println(e);
    		}
    		
    		// establish a connection to FileMaker
    		Connection con;
    		try {
    			con=DriverManager.getConnection("jdbc:sequelink://localhost:2399;serverDataSource=Records");
    		} catch(Exception e) {
    			System.out.println(e);
    		}
    		
    		// get connection warnings + ";serverDataSource=" + dbName
    		/*SQLWarning warning=null;
    		try {
    			warning=con.getWarnings();
    			if (warning==null) {
    				System.out.println("No warnings");
    				return;
    			}
    			while (warning!=null) {
    				System.out.println("Warning: "+warning);
    				warning = warning.getNextWarning();
    			}
    		} catch (Exception e) {
    			System.out.println(e);
    		}*/
    	}
    }
    Further more, are there any special settings needed in FileMaker?
    Please give a comment. Thank you in advanced.

    screen shot:
     

    Attached Files:

  2. garethlewis2 macrumors 6502

    Joined:
    Dec 6, 2006
    #2
    Installing the driver doesn't mean anything. You need to add the location of the JDBC driver to your classpath system variable. That is what Java is telling you.
     
  3. Howiieque thread starter macrumors regular

    Joined:
    Feb 1, 2009
    #3
    Thank you so much for your reply.
    After using the tool ship with that drive, I recognised that the class path wasn't set properly. But the problem is that I don't know how to set it.
    I followed the instruction to install the driver into /Library/Java/Extensions.
    Deep in it, lives a driver folder which including lib folder containing sljc.jar. that's it. I am sure that com.ddtek.jdbc.sequelink.SequeLinkDriver is inside it.
    I am a newbie to Java. Please give a detail explanation. I have been trying to do my homework--making query to database driven by servlet & jsp. I am longing to see your answer again.
     
  4. garethlewis2 macrumors 6502

    Joined:
    Dec 6, 2006
    #4
    Your classpath is set in your login file.

    CLASSPATH=/Library/Java/Extensions/sljc.jar
    export CLASSPATH

    java yourprogramname

    You can put the CLASSPATH definition in either your .bashrc file or your .profile file.
     
  5. Howiieque thread starter macrumors regular

    Joined:
    Feb 1, 2009
    #5
    Thank you for your generous reply.
    I am absolutely don't know unix.
    I typed it in the terminal and it couldn't find my programme this time.
    .bashrc and .profile How can I find them.

    Please explain one more time.
     
  6. Cromulent macrumors 603

    Cromulent

    Joined:
    Oct 2, 2006
    Location:
    The Land of Hope and Glory
    #6
    Open the Terminal application and type the following command:

    nano .profile

    this opens up a command line text editor. Add the correct text and save it by pressing Ctrl + O and then quit by pressing Ctrl + X. This will save it. You may need to log out at this point for the change to take effect.
     
  7. Howiieque thread starter macrumors regular

    Joined:
    Feb 1, 2009
    #7
    Thank you. Thank you very much.
    It has haunted me for a long time and spent me more than a day to solve it.
    May God bless you.

    here is what I put into .profile:
    Code:
    SLJC_DRIVER=/Library/Java/Extensions/driver/lib/sljc.jar
    export SLJC_DRIVER
    CLASSPATH=$SLJC_DRIVER:$CLASSPATH
    export CLASSPATH
    Am I right?
    I am adding both the original one and the driver path to CLASSPATH.
    If I just wrote
    CLASSPATH=/Library/Java/Extensions/driver/lib/sljc.jar
    export CLASSPATH
    then the JVM would fail to find my programm, for it just looked into that path.
    Am I right?

    here is my test code:
    Code:
    import java.sql.*;
    public class test {
    	public static void main(String[] args) {
    		
    		// register the JDBC client driver
    		try {
    			//Driver d=(Driver)Class.forName("com.ddtek.jdbc.sequelink.SequeLinkDriver").newInstance();
    			Class.forName("com.ddtek.jdbc.sequelink.SequeLinkDriver");
    		} catch(Exception e) {
    			System.out.println(e);
    		}
    		
    		// establish a connection to FileMaker
    		Connection con;
    		try {
    			con=DriverManager.getConnection("jdbc:sequelink://localhost:2399; user=Admin; password=Admin; serverDataSource=Records");
    			PreparedStatement statement=con.prepareStatement("SELECT Last_Name FROM Records");
    			ResultSet result=statement.executeQuery();
    			while (result.next()) {
    				String name=result.getString("Last_Name");
    				System.out.println(name);
    			}
    			result.close();
    			statement.close();
    			con.close();
    		} catch(Exception e) {
    			System.out.println(e);
    		}
    		
    		// get connection warnings + ";serverDataSource=" + dbName
    		/*SQLWarning warning=null;
    		try {
    			warning=con.getWarnings();
    			if (warning==null) {
    				System.out.println("No warnings");
    				return;
    			}
    			while (warning!=null) {
    				System.out.println("Warning: "+warning);
    				warning = warning.getNextWarning();
    			}
    		} catch (Exception e) {
    			System.out.println(e);
    		}*/
    	}
    }
    
    Hope that will help anyone encounters this kind of questions.:D;):p
     
  8. Howiieque thread starter macrumors regular

    Joined:
    Feb 1, 2009
    #8
    When dealing with Tomcat, you need to have the driver in /Tomcat/lib:D
     

Share This Page