Würde mich freuen : )
Hier der Code
import java.util.*;
import java.io.*;
import java.util.*;
import java.sql.*;
import java.sql.Date;
import lotus.jdbc.domino.*;
public class jdbcconnect {
public static void main( String[] args )
{
Connection con;
Statement stmt;
ResultSet rs;
ResultSetMetaData rsmd = null;
String name;
String sql = "SELECT * FROM Termine";
System.out.println("1");
String connStr = "jdbc:domino:/DB/SERVER";
System.out.println(connStr);
try {
try {
Class.forName( "lotus.jdbc.domino.DominoDriver" );
}
catch( ClassNotFoundException e ) {
System.out.println( "ClassNotFoundExecption: " + e.getMessage() );
}
System.out.println("3");
System.out.println( "Connecting to URL " + connStr );
System.out.println("4");
con = DriverManager.getConnection( connStr, "USER", "PASSWORT" );
System.out.println("5");
System.out.println();
// Create Statement
stmt = con.createStatement();
System.out.println("6");
// Execute statement
rs = stmt.executeQuery( sql );
System.out.println("7");
System.out.println( "Executing... " + sql );
System.out.println("8");
System.out.println();
// Get Result set metadata
rsmd = rs.getMetaData();
System.out.println("9");
// Find number of columns in the result set
int colCount = rsmd.getColumnCount();
// Array to hold max display size per column
int[] len = new int[colCount+1];
// Print column Labels as header
for( int i=1; i<=colCount; i++ )
{
// Get column label
String label = rsmd.getColumnLabel( i );
// Store the maximum of display size or label length
if( label.length() > 10 )
len = label.length();
else
len = 10;
// Print label
System.out.print( label );
// Pad with blanks
fill( " ", len-label.length() );
// Column seperator
System.out.print( " " );
}
System.out.println();
// Print lines
for( int i=1; i<=colCount; i++ )
{
fill( "-", len );
System.out.print( " " );
}
System.out.println();
// Fetch all rows in the result set
while( rs.next() )
{
// Get all columns as String
for( int i=1; i<=colCount; i++ )
{
Object obj = rs.getObject( i );
boolean nl = rs.wasNull();
if( nl )
printCol( len, "null" );
else
printCol( len, obj.toString() );
}
System.out.println();
}
// Close the statement
stmt.close();
// Close the connection
con.close();
} catch( Exception e ) {
System.out.println( e.getMessage() );
}
}
// Print a string N times
static void fill( String s, int times )
{
if( times <= 0 )
return;
for( int i=0; i<times; i++ )
{
System.out.print( s );
}
}
// Print a column and pad it with blanks + separator
static void printCol( int len, String s )
{
System.out.print( s );
fill( " ", len-s.length() );
System.out.print( " " );
}
}