4 Replies - 1839 Views - Last Post: 19 July 2011 - 09:54 PM Rate Topic: -----

#1 newaudrey  Icon User is offline

  • D.I.C Head

Reputation: -3
  • View blog
  • Posts: 162
  • Joined: 08-July 10

how can i set java ireport datasource programatically?

Posted 19 July 2011 - 05:28 AM

how can i set java ireport datasource programatically?
please sir, ma'am, friends help me
i repost it because i changed the topic title and clearer question
and i can't edit the title name on my other post.

this is my connect claass

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 *
 * 
 */
import java.sql.*;
import javax.swing.*;
public class Connect {
Connection conn = null;
ResultSet rs = null;
PreparedStatement pst = null;
public static Connection ConnectDB(){
    try{
        Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
        Connection conn = DriverManager.getConnection("jdbc:odbc:Driver={Microsoft Access Driver (*.mdb)}; DBQ=Database1.mdb");
        //JOptionPane.showMessageDialog(null, "Connection Established");
        return conn;

    }catch(Exception e){
        JOptionPane.showMessageDialog(null, e);
        return null;
    }
}
}


this is the code for my button

String sql = "Select * from table1";


        try{
            pst = conn.prepareStatement(sql);
        rs = pst.executeQuery();
            String report = "C:\\Users\\newAudrey \\Documents\\NetBeansProjects\\try\\src\\newReport.jrxml";
        JasperReport jr = JasperCompileManager.compileReport(report);
        JasperPrint jp = JasperFillManager.fillReport(jr, null, conn);
JasperViewer.viewReport(jp);
        }catch(Exception e){

        }



the report doesnt show or give me an error.

This post has been edited by newaudrey: 19 July 2011 - 05:29 AM


Is This A Good Question/Topic? 0
  • +

Replies To: how can i set java ireport datasource programatically?

#2 TFoSSDQ  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 123
  • View blog
  • Posts: 253
  • Joined: 09-December 10

Re: how can i set java ireport datasource programatically?

Posted 19 July 2011 - 11:06 AM

Assuming you're connecting correctly to the server, if it's not displaying correctly, are you positive you're accessing the right source? Idk if it'll help since I've only worked with MySQL databases with Java, but you may have to precede the table name with the database name, that's what's required to access specific tables with MySQL, but it looks like you aren't even doing anything with the accessed data, since you don't do anything with the ResultSet. If you set up the Jasper stuff right (never touched on it), then my guess is the Connection.

This post has been edited by TFoSSDQ: 19 July 2011 - 11:09 AM

Was This Post Helpful? 0
  • +
  • -

#3 newaudrey  Icon User is offline

  • D.I.C Head

Reputation: -3
  • View blog
  • Posts: 162
  • Joined: 08-July 10

Re: how can i set java ireport datasource programatically?

Posted 19 July 2011 - 03:49 PM

sir can u give me hints on how to set java ireport datasource programatically?
Was This Post Helpful? 0
  • +
  • -

#4 pbl  Icon User is offline

  • There is nothing you can't do with a JTable
  • member icon

Reputation: 8316
  • View blog
  • Posts: 31,836
  • Joined: 06-March 08

Re: how can i set java ireport datasource programatically?

Posted 19 July 2011 - 09:27 PM

View Postnewaudrey, on 19 July 2011 - 06:49 PM, said:

sir can u give me hints on how to set java ireport datasource programatically?

We are not experts in third parties softwares. We are plain vanilla flavored Java experts (or we pretend so). You migth have better answers on the ireport forum.
Was This Post Helpful? 0
  • +
  • -

#5 newaudrey  Icon User is offline

  • D.I.C Head

Reputation: -3
  • View blog
  • Posts: 162
  • Joined: 08-July 10

Re: how can i set java ireport datasource programatically?

Posted 19 July 2011 - 09:54 PM

sir pbl thanks for youre reply. is there other way to create report in java sir, or are there an easier way to create a report in java? except using third party softwares?
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1