2010-04-08 1 views
0
package collabsoft.backlog_reports.c4; 



import java.sql.CallableStatement; 
import java.sql.Connection; 
import java.sql.DriverManager; 
import java.sql.ResultSet; 
import java.sql.ResultSetMetaData; 
import java.sql.Statement; 

//import collabsoft.backlog_reports.c4.Report; 

public class Report { 

private Connection con; 

public Report(){ 
    connectUsingJDBC(); 
} 
public static void main(String args[]){ 
    Report dc = new Report(); 
    dc.reviewMeeting(6, 8, 10); 
dc.createReport("dede",100); 
//dc.viewReport(100); 
// dc.custRent(3344,123,22,11-11-2009); 
} 

/** 
    the following method is used to connect to the database 
**/ 


public void connectUsingJDBC() { 
    // This is the name of the ODBC data source 
    String dataSourceName = "Simple_DB"; 
    try { 
    // loading the driver in the memory 
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); 
    // This is the connection URL 
    String dbURL = "jdbc:odbc:" + dataSourceName; 
    con = DriverManager.getConnection("jdbc:mysql://localhost:3306/Collabsoft","root",""); 
    // This line is used to print the name of the driver and it would throw an exception if a problem occured 
    System.out.println("User connected using driver: " + con.getMetaData().getDriverName()); 

    //Addcustomer(con,1111,"aaa","aaa","aa","aam","111","2222","111"); 
    //rentedMovies(con); 
    //executePreparedStatement(con); 
    //executeCallableStatement(con); 
    //executeBatch(con); 

    } catch (Exception e) { 
    e.printStackTrace(); 
    } 
} 

/** 
    *this code is to link the SQL code with the java for the task 
    *as an admin I should be able to create a report of a review meeting including notes, tasks and users 
    *i will take the task id and user id and note id that will be needed to be added in the review 
    *meeting report and i will display the information related to these ida 
    **/ 




    public void reviewMeeting(int taskID, int userID, int noteID)// law el proc bt return table 
{ 
    try{ 
    CallableStatement callableStatement = con.prepareCall("{CALL report_review_meeting(?,?,?)}"); 

     callableStatement.setInt(1,taskID); 
         callableStatement.setInt(2,userID); 
         callableStatement.setInt(3,noteID); 

    ResultSet resultSet = callableStatement.executeQuery(); // or executeupdate() or updateQuery 
    ResultSetMetaData rsm = resultSet.getMetaData(); 
    int numOfColumns = rsm.getColumnCount(); 
    System.out.println("lojayna"); 

    while (resultSet.next()) 
    { 
    System.out.println("New Row:"); 
    for (int i = 1; i <= numOfColumns; i++) 
    System.out.print(rsm.getColumnName(i) + ": " + resultSet.getObject(i) + " "); 
    System.out.println(); 
    } 
    } 
    catch(Exception e) 
    { 
    System.out.println("E"); 
    } 
} 



    ////////////////////////////////// 
    ///////////////////////////////// 



    public void allproject(int projID)// law el proc bt return table 
    { 
    try{ 
    CallableStatement callableStatement = con.prepareCall("{CALL all_project(?)}"); 

      callableStatement.setInt(1,projID); 
          //callableStatement.setInt(2,userID); 
          //callableStatement.setInt(3,noteID); 

    ResultSet resultSet = callableStatement.executeQuery(); // or executeupdate() or updateQuery 
    ResultSetMetaData rsm = resultSet.getMetaData(); 
    int numOfColumns = rsm.getColumnCount(); 
    System.out.println("lojayna"); 

    while (resultSet.next()) 
    { 
     System.out.println("New Row:"); 
     for (int i = 1; i <= numOfColumns; i++) 
     System.out.print(rsm.getColumnName(i) + ": " + resultSet.getObject(i) + " "); 
     System.out.println(); 
    } 
    } 
    catch(Exception e) 
    { 
    System.out.println("E"); 
    } 
    } 














    /////////////////////////////// 












    /** 
    * here i take the event id and i take a string report and then 
    * i relate the report with the event 

    **/ 




    public void createReport(String report,int E_ID)// law el proc bt return table 
    { 
    try{ 





    Statement st = con.createStatement(); 

    st.executeUpdate("UPDATE e_vent SET e_vent.report=report WHERE e_vent.E_ID= E_ID;"); 

    /* CallableStatement callableStatement = con.prepareCall("{CALL Create_report(?,?)}"); 

      callableStatement.setString(1,report); 
          callableStatement.setInt(2,E_ID); 


    ResultSet resultSet = callableStatement.executeQuery(); // or executeupdate() or updateQuery 
    ResultSetMetaData rsm = resultSet.getMetaData(); 
    int numOfColumns = rsm.getColumnCount(); 
    System.out.println("lojayna"); 

    while (resultSet.next()) 
    { 
     System.out.println("New Row:"); 
     for (int i = 1; i <= numOfColumns; i++) 
     System.out.print(rsm.getColumnName(i) + ": " + resultSet.getObject(i) + " "); 
     System.out.println(); 
    }*/ 
    } 
    catch(Exception e) 
    { 
    System.out.println("E"); 
    System.out.println(e); 
    } 
    } 




/** 
    *in the following method i view the report of the event having the ID eventID 
    **/ 





    public void viewReport(int eventID)// law el proc bt return table 
{ 
    try{ 
    CallableStatement callableStatement = con.prepareCall("{CALL view_report(?)}"); 

     callableStatement.setInt(1,eventID); 



    ResultSet resultSet = callableStatement.executeQuery(); // or executeupdate() or updateQuery 
    ResultSetMetaData rsm = resultSet.getMetaData(); 
    int numOfColumns = rsm.getColumnCount(); 
    System.out.println("lojayna"); 

    while (resultSet.next()) 
    { 
    System.out.println("New Row:"); 
    for (int i = 1; i <= numOfColumns; i++) 
    System.out.print(rsm.getColumnName(i) + ": " + resultSet.getObject(i) + " "); 
    System.out.println(); 
    } 
    } 
    catch(Exception e) 
    { 
    System.out.println("E"); 
    } 
} 





















} 

// 콘솔에서이 메서드의 결과가 표시되는 중입니다. WIcket을 사용하고 있는데, 웹에서 보여줄 수있는 2 가지 방법이 있습니까?콘솔에 나타나는 출력을 전송하고 웹 페이지에 나타나도록 포맷 할 수 있습니까?

+4

코드를 포맷해야합니다. – LB40

+1

질문을 더 짧고 간결하게 작성하십시오. –

+3

http://catb.org/esr/faqs/smart-questions.html 및 http://sscce.org를 읽고 메시지 형식에주의하십시오. 자세한 내용은 FAQ를 확인하고 메시지 미리보기 (메시지 편집기 맨 아래에 있음)를 사용하여 올바른 것이 있는지 확인하십시오. 바로 지금 당신의 편에서 어떤 노력도하지 않고 무관심한 copy'n'paste 액션처럼 보입니다. 포럼 및 품질 보증 사이트에 대한 사실은 귀하가 직접 입력 한 것보다 많은 노력을 기울여야한다는 것입니다. – BalusC

답변

0

원하는 경우 HTML 페이지에 텍스트를 덤프하거나 StringBuilder를 사용하거나 HTML 태그가있는 텍스트를 출력하는 메소드가있는 추가 클래스를 만듭니다.

실제로 웹 사이트에 애니메이션을 적용하려는 경우 가장 간단한 방법은 서블릿을 사용하는 것입니다. 튜토리얼에 대해서는 아래 링크를 참조하십시오.

http://www.java-tips.org/java-tutorials/tutorials/introduction-to-java-servlets-with-eclipse.html

0

당신은 간단한 해결책은 제임스의 대답 이동합니다. 그러나 응용 프로그램이나 플랫폼간에 데이터를 비동기 적으로 전송해야하는 경우 (로컬이 아닌 이중 시간) JMS api을보고 싶을 수도 있습니다. Glassfish를 응용 프로그램 서버로 사용하는 경우 매우 쉽거나 Apache ActiveMQ 구현이 잘 수행됩니다). 시스템 프로그램/스크립트가 webapp에서 호출되고 배포가 끝나면 JMS를 통해 이러한 프로그램이 webapp에 다시보고되는 배포에서이 프로그램을 사용하고 있습니다.

또는 출력을 데이터베이스로 덤프 할 수도 있습니다.