Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import sqlj.runtime.*;
- import sqlj.runtime.ref.*;
- import java.sql.*;
- import java.io.*;
- public class sqlj_1 {
- private static Ctx myCtx;
- private static BufferedReader in;
- public static void aufgabe1() {
- String birthday;
- double salary;
- String nName = "HAAS";
- String vName = "CHRISTINE";
- try {
- // (1) Verbindungsaufbau
- Class.forName("com.igb.db2.jcc.DB2Driver");
- DefaultContext.setDefaultContext(new DefaultContext("jdbc:db2://139.30.3.158:50000/sample", "db2newby", "dbap10", false));
- #sql {SELECT BIRTHDATE, SALARY FROM db2inst1.EMPLOYEE WHERE FIRSTNME = :vName AND LASTNAME = :nName};
- System.out.print(birthday + " und " + salary + " sind die Ergebnisse!");
- } catch (Exception e) {
- }
- }
- public static void aufgabe2() {
- String myFirstname;
- String myLastname;
- String projectNumber = 1;
- try {
- // (1) Verbindungsaufbau
- Class.forName("com.igb.db2.jcc.DB2Driver");
- DefaultContext.setDefaultContext(new DefaultContext("jdbc:db2://139.30.3.158:50000/sample", "db2newby", "dbap10", false));
- #sql {SELECT
- db2inst1.EMPLOYEE.FIRSTNME AS myFirstname, db2inst1.EMPLOYEE.LASTNAME AS myLastname
- FROM
- db2inst1.EMP_ACT
- JOIN
- db2inst1.EMPLOYEE ON db2inst1.EMP_ACT.EMPNO = db2inst1.EMPLOYEE.EMPNO
- WHERE
- db2inst1.EMP_ACT.PROJNO = :projectNumber};
- } catch {Exception e) {
- }
- }
- public static void main() {
- aufgabe1();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement