- Registriert
- 29.03.07
- Beiträge
- 799
Ich muss für die Uni ein Java-Programm schreiben, was sich mit einer DB2-Datenbank verbinden soll.
Hier die Aufgabe:
Könnt ihr euch vorstellen, was mit " Signature should look like this: public Connection getDBLABConnection() throws SQLException" gemeint ist?
So sieht mein Code bisher aus:
Bisher macht das Programm eigentlich nichts, da ich nicht weiß, wie man dieses "getDBLABConnection()" startet.
Könnt ihr mir weiterhelfen?
Hier die Aufgabe:
Tasks
a) Write a Java method establishing a connection to our DB2 database. The Connection object is to be returned by the method. Signature should look like this: public Connection getDBLABConnection() throws SQLException
Hint: Set the retrieveMessagesFromServerOnGetMessage property to true during
connection initialization in order to obtain verbose exceptions from the JDBC driver.
Könnt ihr euch vorstellen, was mit " Signature should look like this: public Connection getDBLABConnection() throws SQLException" gemeint ist?
So sieht mein Code bisher aus:
Code:
package sql5;
import java.sql.*;
import java.sql.Connection;
import com.ibm.db2.jcc.*;
public class aufgabe_a {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
try {
Class.forName("com.ibm.db2.jcc.DB2Driver");
}
catch(java.lang.ClassNotFoundException e) {
System.err.print("ClassNotFoundException: ");
System.err.println(e.getMessage());
}
}
public Connection getDBLABConnection() throws SQLException {
String url = "jdbc:db2://url";
Connection con = null;
con = DriverManager.getConnection(url, "name", "passwort");
return con;
}
}
Bisher macht das Programm eigentlich nichts, da ich nicht weiß, wie man dieses "getDBLABConnection()" startet.
Könnt ihr mir weiterhelfen?