Visualizzazione dei risultati da 1 a 2 su 2
  1. #1

    Crystal report su Apache

    Ciao a tutti scusate se sbaglio il settore del post ma non ho la più pallida idea di dove postare qualcosa di Crystal report. Questo è un pezzo di codice contenuto in un .jsp
    che dovrebbe stampare a video un report passandogli delle query implementate su sql2000, non riesco a capire l'errore voi potete darmi una mano??
    questo è il codice completo l'errore me lo da alla riga 139.

    <%@page import="com.businessobjects.samples.JRCHelperSampl e,
    com.crystaldecisions.reports.sdk.ReportClientDocum ent,
    com.crystaldecisions.sdk.occa.report.application.O penReportOptions,
    com.crystaldecisions.sdk.occa.report.lib.ReportSDK ExceptionBase,
    java.sql.Connection,
    java.sql.DriverManager,
    java.sql.ResultSet,
    java.sql.SQLException,
    java.sql.Statement"%><%
    // This sample code calls methods from the JRCHelperSample class, which
    // contains examples of how to use the BusinessObjects APIs. You are free to
    // modify and distribute the source code contained in the JRCHelperSample class.

    try {

    String reportName = "CrystalReport1.rpt";
    ReportClientDocument clientDoc = (ReportClientDocument) session.getAttribute(reportName);

    if (clientDoc == null) {
    // Report can be opened from the relative location specified in the CRConfig.xml, or the report location
    // tag can be removed to open the reports as Java resources or using an absolute path
    // (absolute path not recommended for Web applications).

    clientDoc = new ReportClientDocument();

    // Open report
    clientDoc.open(reportName, OpenReportOptions._openAsReadOnly);


    // ****** BEGIN POPULATE WITH RESULTSET SNIPPET ****************
    {
    // **** POPULATE MAIN REPORT ****
    {
    // Connection Info for fetching the resultSet
    String connectStr = "jdbc:microsoft:sqlserver://localhost:1433;databaseName=Giulio2";
    String driverName = "com.microsoft.jdbc.sqlserver.SQLServerDriver" ;
    String userName = "xx"; // TODO: Fill in database user
    String password = "xxxxxx"; // TODO: Fill in valid password

    // TODO: Ensure this query is valid in your database. An exception will be thrown otherwise.
    String query = "SELECT CITTADINANZA FROM ANAGRAFICA_PUERPERA";

    // As long the Resultset schema has the same field names and types,
    // then the Resultset can be used as the datasource for the table
    String tableAlias = "Anagrafica_puerpera"; // TODO: Change to correct table alias

    // Push the Java ResultSet into the report (this will then be the datasource of the report)
    JRCHelperSample.passResultSet(clientDoc, fetchResultSet(driverName, connectStr, userName, password, query),
    tableAlias, "");
    }

    // **** POPULATE MAIN REPORT ****
    {
    // Connection Info for fetching the resultSet
    String connectStr = "jdbc:microsoft:sqlserver://localhost:1433;databaseName=Giulio2";
    String driverName = "com.microsoft.jdbc.sqlserver.SQLServerDriver" ;
    String userName = "xx"; // TODO: Fill in database user
    String password = "xxxxx"; // TODO: Fill in valid password

    // TODO: Ensure this query is valid in your database. An exception will be thrown otherwise.
    String query = "SELECT PROVINCIA FROM ANAGRAFICA_STRUTTURE_OSPEDALIERE";

    // As long the Resultset schema has the same field names and types,
    // then the Resultset can be used as the datasource for the table
    String tableAlias = "Anagrafica_strutture_ospedaliere"; // TODO: Change to correct table alias

    // Push the Java ResultSet into the report (this will then be the datasource of the report)
    JRCHelperSample.passResultSet(clientDoc, fetchResultSet(driverName, connectStr, userName, password, query),
    tableAlias, "");
    }

    // **** POPULATE MAIN REPORT ****
    {
    // Connection Info for fetching the resultSet
    String connectStr = "jdbc:microsoft:sqlserver://localhost:1433;databaseName=Giulio2";
    String driverName = "com.microsoft.jdbc.sqlserver.SQLServerDriver" ;
    String userName = "xx"; // TODO: Fill in database user
    String password = "xxxxxx"; // TODO: Fill in valid password

    // TODO: Ensure this query is valid in your database. An exception will be thrown otherwise.
    String query = "SELECT MEDICO FROM CEDAP";

    // As long the Resultset schema has the same field names and types,
    // then the Resultset can be used as the datasource for the table
    String tableAlias = "CedAP"; // TODO: Change to correct table alias

    // Push the Java ResultSet into the report (this will then be the datasource of the report)
    JRCHelperSample.passResultSet(clientDoc, fetchResultSet(driverName, connectStr, userName, password, query),
    tableAlias, "");
    }

    // **** POPULATE MAIN REPORT ****
    {
    // Connection Info for fetching the resultSet
    String connectStr = "jdbc:microsoft:sqlserver://localhost:1433;databaseName=Giulio2";
    String driverName = "com.microsoft.jdbc.sqlserver.SQLServerDriver" ;
    String userName = "xx"; // TODO: Fill in database user
    String password = "xxxxxx"; // TODO: Fill in valid password

    // TODO: Ensure this query is valid in your database. An exception will be thrown otherwise.
    String query = "SELECT NOME_MADRE FROM DICHIARAZIONE_NASCITA";

    // As long the Resultset schema has the same field names and types,
    // then the Resultset can be used as the datasource for the table
    String tableAlias = "Dichiarazione_nascita"; // TODO: Change to correct table alias

    // Push the Java ResultSet into the report (this will then be the datasource of the report)
    JRCHelperSample.passResultSet(clientDoc, fetchResultSet(driverName, connectStr, userName, password, query),
    tableAlias, "");
    }


    }
    // ****** END POPULATE WITH RESULTSET SNIPPET ****************


    // Store the report document in session
    session.setAttribute(reportName, clientDoc);

    }



    } catch (ReportSDKExceptionBase e) {
    out.println(e);
    } catch (SQLException e) {
    out.println(e);
    }

    %><%!
    // Simple utility function for obtaining result sets that will be pushed into the report.
    // This is just standard querying of a Java result set and does NOT involve any
    // Crystal JRC SDK functions.

    private static ResultSet fetchResultSet(String driverName,
    String connectStr, String userName, String password, String query) throws SQLException, ClassNotFoundException {

    //Load JDBC driver for the database that will be queried
    Class.forName(driverName); ----> riga 139;

    Connection connection = DriverManager.getConnection(connectStr, userName, password);
    Statement statement = connection.createStatement(ResultSet.TYPE_SCROLL_I NSENSITIVE, ResultSet.CONCUR_READ_ONLY);

    //Execute query and return result sets
    return statement.executeQuery(query);

    }%>

    Secondo la mia ignoranza l'errore non è proprio sulla riga 139 ma li intorno...
    Scusate di tutto il malloppo ma non sapendo se postere solo intrno all'arrore oppure postare tutto il codice ho scelto la seconda scusate ma sto impazzendo da 4 giorni su questo codice di pupu......
    Emix!!

  2. #2
    Utente di HTML.it
    Registrato dal
    Aug 2002
    Messaggi
    8,013

    Re: Crystal report su Apache

    Indenta, con [*code] [/*code] (senza gli asterischi) e aggiungi che errore ricevi e possibilmente qual è la riga 139
    codice:
    <%@page import="com.businessobjects.samples.JRCHelperSample,
    com.crystaldecisions.reports.sdk.ReportClientDocument,
    com.crystaldecisions.sdk.occa.report.application.OpenReportOptions,
    com.crystaldecisions.sdk.occa.report.lib.ReportSDKExceptionBase,
    java.sql.Connection,
    java.sql.DriverManager,
    java.sql.ResultSet,
    java.sql.SQLException,
    java.sql.Statement"%><%
    	// This sample code calls methods from the JRCHelperSample class, which 
    	// contains examples of how to use the BusinessObjects APIs. You are free to 
    	// modify and distribute the source code contained in the JRCHelperSample class. 
    
    	try {
    
    		String reportName = "CrystalReport1.rpt";
    		ReportClientDocument clientDoc = (ReportClientDocument) session.getAttribute(reportName);
    
    		if (clientDoc == null) {
    			// Report can be opened from the relative location specified in the CRConfig.xml, or the report location
    			// tag can be removed to open the reports as Java resources or using an absolute path
    			// (absolute path not recommended for Web applications).
    
    			clientDoc = new ReportClientDocument();
    			
    			// Open report
    			clientDoc.open(reportName, OpenReportOptions._openAsReadOnly);
    
    		
    			// ****** BEGIN POPULATE WITH RESULTSET SNIPPET ****************  
    			{
    				// **** POPULATE MAIN REPORT ****
    				{
    					 // Connection Info for fetching the resultSet
    					String connectStr = "jdbc:microsoft:sqlserver://localhost:1433;databaseName=Giulio2";
    					String driverName = "com.microsoft.jdbc.sqlserver.SQLServerDriver";
    					String userName = "xx";		// TODO: Fill in database user
    					String password = "xxxxxx";	// TODO: Fill in valid password
    					
    					// TODO: Ensure this query is valid in your database. An exception will be thrown otherwise.
    					String query = "SELECT CITTADINANZA FROM ANAGRAFICA_PUERPERA";
    
    					// As long the Resultset schema has the same field names and types,
    					// then the Resultset can be used as the datasource for the table
    					String tableAlias = "Anagrafica_puerpera";		// TODO: Change to correct table alias
    
    					// Push the Java ResultSet into the report (this will then be the datasource of the report)
    					JRCHelperSample.passResultSet(clientDoc, fetchResultSet(driverName, connectStr, userName, password, query),
    						tableAlias, "");
    				}
    
    				// **** POPULATE MAIN REPORT ****
    				{
    					 // Connection Info for fetching the resultSet
    					String connectStr = "jdbc:microsoft:sqlserver://localhost:1433;databaseName=Giulio2";
    					String driverName = "com.microsoft.jdbc.sqlserver.SQLServerDriver";
    					String userName = "xx";		// TODO: Fill in database user
    					String password = "xxxxx";	// TODO: Fill in valid password
    
    					// TODO: Ensure this query is valid in your database. An exception will be thrown otherwise.
    					String query = "SELECT PROVINCIA FROM ANAGRAFICA_STRUTTURE_OSPEDALIERE";
    
    					// As long the Resultset schema has the same field names and types,
    					// then the Resultset can be used as the datasource for the table
    					String tableAlias = "Anagrafica_strutture_ospedaliere";		// TODO: Change to correct table alias
    
    					// Push the Java ResultSet into the report (this will then be the datasource of the report)
    					JRCHelperSample.passResultSet(clientDoc, fetchResultSet(driverName, connectStr, userName, password, query),
    						tableAlias, "");
    				}
    
    				// **** POPULATE MAIN REPORT ****
    				{
    					 // Connection Info for fetching the resultSet
    					String connectStr = "jdbc:microsoft:sqlserver://localhost:1433;databaseName=Giulio2";
    					String driverName = "com.microsoft.jdbc.sqlserver.SQLServerDriver";
    					String userName = "xx";		// TODO: Fill in database user
    					String password = "xxxxxx";	// TODO: Fill in valid password
    
    					// TODO: Ensure this query is valid in your database. An exception will be thrown otherwise.
    					String query = "SELECT MEDICO FROM CEDAP";
    
    					// As long the Resultset schema has the same field names and types,
    					// then the Resultset can be used as the datasource for the table
    					String tableAlias = "CedAP";		// TODO: Change to correct table alias
    
    					// Push the Java ResultSet into the report (this will then be the datasource of the report)
    					JRCHelperSample.passResultSet(clientDoc, fetchResultSet(driverName, connectStr, userName, password, query),
    						tableAlias, "");
    				}
    
    				// **** POPULATE MAIN REPORT ****
    				{
    					 // Connection Info for fetching the resultSet
    					String connectStr = "jdbc:microsoft:sqlserver://localhost:1433;databaseName=Giulio2";
    					String driverName = "com.microsoft.jdbc.sqlserver.SQLServerDriver";
    					String userName = "xx";		// TODO: Fill in database user
    					String password = "xxxxxx";	// TODO: Fill in valid password
    
    					// TODO: Ensure this query is valid in your database. An exception will be thrown otherwise.
    					String query = "SELECT NOME_MADRE FROM DICHIARAZIONE_NASCITA";
    
    					// As long the Resultset schema has the same field names and types,
    					// then the Resultset can be used as the datasource for the table
    					String tableAlias = "Dichiarazione_nascita";		// TODO: Change to correct table alias
    
    					// Push the Java ResultSet into the report (this will then be the datasource of the report)
    					JRCHelperSample.passResultSet(clientDoc, fetchResultSet(driverName, connectStr, userName, password, query),
    						tableAlias, "");
    				}
    
    
    			}
    			// ****** END POPULATE WITH RESULTSET SNIPPET ****************
    		
    		
    			// Store the report document in session
    			session.setAttribute(reportName, clientDoc);
    
    		}
    
    		
    
    	} catch (ReportSDKExceptionBase e) {
    	    out.println(e);
    	} catch (SQLException e) {
            out.println(e);
        }
    	
    %><%!
    // Simple utility function for obtaining result sets that will be pushed into the report.  
    // This is just standard querying of a Java result set and does NOT involve any 
    // Crystal JRC SDK functions. 
    
    	private static ResultSet fetchResultSet(String driverName,
    			String connectStr, String userName, String password, String query) throws SQLException, ClassNotFoundException {
    
    		//Load JDBC driver for the database that will be queried	
    		Class.forName(driverName);  ----> riga 139;
    
    		Connection connection = DriverManager.getConnection(connectStr, userName, password);
    		Statement statement = connection.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);
    
    		//Execute query and return result sets
    		return statement.executeQuery(query);
    
    }%>
    <´¯)(¯`¤._)(¯`»ANDREA«´¯)(_.¤´¯)(¯`>
    "The answer to your question is: welcome to tomorrow"

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.