hallo bin neu hier und habe ein problem mit dem teil...
da ist soll ein fehler sein aber wo? danke für antworten
import java.sql.*;
public class connectURL {
public static void main(String[] args) {
// Create a variable for the connection string.
String connectionUrl = "jdbc:sqlserver://HAIRER_NB/SQLEXPRESS:1433;" +
"databaseName=BoardMIT_Staging;integratedSecurity=true;";
// Declare the JDBC objects.
Connection con = null;
Statement stmt = null;
ResultSet rs = null;
try {
// Establish the connection.
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
con = DriverManager.getConnection(connectionUrl);
// Create and execute an SQL statement that returns some data.
/*String SQL = "SELECT " +
"perioden.K004_ABR" +
//", TYPE = 'I2'" +
",company.K001_GES" +
",substring(account.K010_KTO,7,10)" +
",account.K010_BIL_GUV_KNZ" +
",ic_company.K001_GES " +
"FROM " +
"[BoardMIT_Staging].[dbo].[extr_ora_K010] as account " +
"CROSS JOIN extr_ora_K004 as perioden" +
"CROSS JOIN extr_ora_K001 as company" +
"CROSS JOIN extr_ora_K001 as ic_company " +
"WHERE " +
"Convert(CHAR(8), perioden.K004_ABR, 112) > 20051201" +
"AND (account.K010_KTO like 'EGLO%')" +
"AND account.K010_KTO_KNZ = 'I' " +
"AND account.K010_K001_GES is NULL" +
"AND company.K001_GES != ic_company.K001_GES"; */
String SQL = "SELECT top 80" +
"[perioden].[K004_ABR]" +
",TYPE = 'I2'" +
",[company].[K001_GES]" +
",substring([account].[K010_KTO],7,10)" +
",[account].[K010_BIL_GUV_KNZ]" +
",[salden].[K039_WERT_LW]" +
"FROM extr_ora_K010 as [account]" +
"CROSS JOIN extr_ora_K004 as [perioden]" +
"CROSS JOIN extr_ora_K001 as [company]" +
"CROSS JOIN extr_ora_K001 as [ic_company]" +
"LEFT OUTER JOIN [BoardMIT_Staging].[dbo].[extr_ora_K039] as salden ON" +
"[perioden].[K004_ABR] = [salden].[K039_ABR_MON_JAHR] " +
"AND [account].[K010_KTO] = [salden].[K039_K010_KTO]" +
"AND [company].[K001_GES] = [salden].[K039_K001_GES]" +
"AND [ic_company].[K001_GES] = [salden].[K039_K001_GES_AN]" +
"AND [salden].[K039_K011_FAC] = 'I1'" +
"WHERE Convert(CHAR(8), [perioden].[K004_ABR], 112) > 20051201" +
"AND[account].[K010_KTO] like 'EGLO%'" +
"AND [account].[K010_KTO_KNZ] = 'I' " +
"AND [account].[K010_K001_GES] is NULL " +
"AND [company].[K001_GES] != [ic_company].K001_GES";
stmt = con.createStatement();
rs = stmt.executeQuery(SQL);
// Iterate through the data in the result set and display it.
while (rs.next()) {
System.out.println(rs.getString(1) + " " +
rs.getString(2) + " " +
rs.getString(3) + " " +
rs.getString(4) + " " +
rs.getString(5) + " " +
rs.getString(6)
);
}
}
// Handle any errors that may have occurred.
catch (Exception e) {
e.printStackTrace();
}
finally {
if (rs != null) try { rs.close(); } catch(Exception e) {}
if (stmt != null) try { stmt.close(); } catch(Exception e) {}
if (con != null) try { con.close(); } catch(Exception e) {}
}
}
}