SQL/MX Programming Manual for Java

Sample Programs
HP NonStop SQL/MX Programming Manual for Java523726-003
C-20
Translating the Program
Translating the Program
At an OSS prompt, enter this command to translate the SQLJ source file by running
the SQLJ translator:
java sqlj.tools.Sqlj -createMDF StreamParcels.sqlj
Running the Program
At an OSS prompt, enter this command to run the SQLJ program:
java StreamParcels
// Wait for newly arrived parcels and notify receivers
while (true)
{
#sql { FETCH :arrivals
INTO :destination, :origin, :seqnbr };
System.out.println("Destination = " + destination);
System.out.println("Origin = " + origin);
System.out.println("Sequence number = " + seqnbr);
System.out.println();
#sql { COMMIT WORK }; /* Commit the transaction */
#sql { BEGIN WORK }; /* Start a new transaction */
}
}
catch (SQLException e)
{
System.out.println("Sqlcode: " + e.getErrorCode());
System.out.println("Message: " + e.getMessage());
System.out.println("Sqlstate: " + e.getSQLState());
}
}
}
Example C-5. StreamParcels.sqlj—Stream Access Mode (page 2 of 2)