You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

79 lines
2.1 KiB

package hsfulda.de;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.util.HashMap;
public class FedConnection implements FedConnectionInterface {
HashMap<Integer, Connection> connections = new HashMap<Integer, Connection>();
String connectionStrings[] = {
"jdbc:oracle:thin:@pinatubo.informatik.hs-fulda.de:1521:ORALV8A",
"jdbc:oracle:thin:@mtsthelens.informatik.hs-fulda.de:1521:ORALV9A",
"jdbc:oracle:thin:@krakatau.informatik.hs-fulda.de:1521:ORALV10A" };
public FedConnection(String username, String password) throws FedException {
try {
DriverManager.registerDriver(new oracle.jdbc.OracleDriver());
for (int i = 0; i < connectionStrings.length; i++) {
connections.put(i, DriverManager.getConnection(connectionStrings[i], username, password));
}
} catch (SQLException sqlException) {
throw new FedException(sqlException);
}
}
public void setAutoCommit(boolean autoCommit) throws FedException {
try {
for (Object i : connections.keySet()) {
connections.get(i).setAutoCommit(autoCommit);
}
} catch (SQLException sqlException) {
throw new FedException(sqlException);
}
}
public boolean getAutoCommit() throws FedException {
boolean autoCommit = false;
try {
autoCommit = connections.get(0).getAutoCommit();
} catch (SQLException sqlException) {
throw new FedException(sqlException);
}
return autoCommit;
}
public void commit() throws FedException {
try {
for (Object i : connections.keySet()) {
connections.get(i).commit();
}
} catch (SQLException sqlException) {
throw new FedException(sqlException);
}
}
public void rollback() throws FedException {
try {
for (Object i : connections.keySet()) {
connections.get(i).rollback();
}
} catch (SQLException sqlException) {
throw new FedException(sqlException);
}
}
public void close() throws FedException {
try {
for (Object i : connections.keySet()) {
connections.get(i).close();
}
} catch (SQLException sqlException) {
throw new FedException(sqlException);
}
}
public FedStatement getStatement() {
return new FedStatement(this);
}
}