Jump to content
Server Maintenance This Week. ×

getting started with JDBC--java error on simple program


Deed

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

Recommended Posts

Hi, question about my first foray into JDBC:

Background: FM Pro Advanced 11, intermediate user, not a Java programmer, Mac OS 10.7, latest Java update installed, downloaded FM JDBC driver (fmjdbc.jar) from FM website, copied to /Library/Java/Extensions as instructed.

Tried to copy and compile the short Java program in the FM ODBC/JDBC manual to confirm connectivity, (BTW, why would that manual have a sample program with the message "Note This example is not meant to be compiled."--not nice!), and got an error.

Source code:

import java.sql.*;

class FMPJDBCTest

{

public static void main(String[ ] args)

{

// register the JDBC client driver

try {

Driver d = (Driver)Class.forName("com.filemaker.jdbc.Driver").newInstance();

} catch(Exception e) {

System.out.println(e);

}

// establish a connection to FileMaker

Connection con;

try {

con = DriverManager.getConnection("jdbc:filemaker://127.0.0.1/locations Converted","admin", "admin");

} catch(Exception e) {

System.out.println(e);

}

// get connection warnings

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);

}

} }

Compile error:

javac ~/Desktop/FMPJDBCTest.java

/Users/wdockery/Desktop/FMPJDBCTest.java:22: variable con might not have been initialized

warning = con.getWarnings();

^

Advice on how to proceed? Thanks--

Link to comment
Share on other sites

This topic is 4228 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.