Jump to content
Server Maintenance This Week. ×

Example Code for JDBC?


This topic is 6511 days old. Please don't post here. Open a new topic instead.

Recommended Posts

  • Newbies

I am trying to add the ability to export data from a 100% java database (HsqlDB) to a FileMaker 8 database in a java application. I am trying to find example java code which shows the jdbc connection specific to using jdbc with Filemaker. I'm having a hard time figuring out how to use the included jdbc driver and I'm hoping some example code would help.

Anyone know how to do this?

Thanks

PD

Link to comment
Share on other sites

  • 2 weeks later...

1. Create new text file with the codes below and name it 'InsertSample.java'.

2. Compile it. [ javac InsertSample.java ]

3. Copy FileMaker JDBC client driver ('sljc.jar') to the same directory.

4. Run it. [ java -cp .:sljc.jar InsertSample ]


import java.sql.*;



public class InsertSample

{

  public static void main(String[] args)

  {

      try

      {

        // Load driver.

        Class.forName("com.ddtek.jdbc.sequelink.SequeLinkDriver");

        // Get connection.

        Connection con = DriverManager.getConnection( "jdbc:sequelink://127.0.0.1:2399;serverdatasource=DATABASE_NAME", "admin", "" );

        

        String sql = "INSERT INTO TABLE_NAME (FIELD_NAME) values ('VALUE')";

        Statement stmt = con.createStatement();

        int result = stmt.executeUpdate(sql);



        // Closing connection.

        con.close();

      }

      catch ( Exception e ) { e.printStackTrace(); }

  }

}

--

Replace the IP address, DATABASE_NAME, TABLE_NAME and FIELD_NAME as you need.

DATABASE_NAME is the name of the filemaker database file without extension.

TABLE_NAME and FIELD_NAME should be surrounded with double quotes (some particular words cause parse error).

Note that you have to configure the sharing settings of the database to allow some users to access via JDBC.

Hope this helps.

Link to comment
Share on other sites

This topic is 6511 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.