I have many lines of <%%> java in my JSP pages. Is it giving much impact?
wild_angel 0 Newbie Poster
hi dean_gobler thanks for your reply. Ah..I see what you mean. But, do you know how to make it faster? Because when hardcode it's only take 1 minute, but when I used parameter it will take 10 minute. It's impossible to use hardcode because user can choose the year and month (parameter) from combobox. :(
wild_angel 0 Newbie Poster
Hi All,
I don't know if I'm asking it right. I have a jsp for monthly report that calling java class and passing date parameter (year and month) into that java class. The java class has a statement that call procedure in database. It's so time consuming to show the report. But when I do hardcode in procedure for date parameter, the report shows much faster. I already checked the passing parameter and it has correct value. Any idea how this thing can happen? Thanks for your reply.
wild_angel 0 Newbie Poster
Hi all,
I have a problem with jsp. I created jsp and there is a table within this page. The columns are based on query from database. When the datas are not too many, the table looks fine. But when it has so many datas the table got messy. But what I don't understand, when I load the jsp in internet explorer, the table looks fine with same many datas.
Can anyone please help how to solve this?
This is a part of my codes:
<div style="overflow:auto;width:800px;">
<!-- BODY -->
<% int widthA = 65 * firstcode_count + 160; %>
<% if (widthA < 800) { widthA = 800; }%>
<% int len1 = 0; %>
<table width=<%= widthA %> border="0" cellpadding="0" cellspacing="0">
<tr class="featurecontentbold" align="right" bgcolor="#EDF395">
<th width=40><%= widthA %></th>
<th align="center" width=100>Time Range</th>
<% for (int i = 0; i < firstcode_count; i++) {
String firstCode = firstCodes.O_FIRST_SELECTION[i].trim(); %>
<th width=65><%= firstCode %></th><% } %>
<th width=20></th>
</tr>
<tr bgcolor="#CCCCCC" class="featurecontent">
<td colspan="<%= firstcode_count + 3 %>"><img src="../../images/line.gif" width="<%= widthA %>" height="3"></td>
</tr>
<% int idx = 0;
int[] totalTrans = new int[firstcode_count];
// initialize
for (int i = 0; i < firstcode_count; i++) { totalTrans[i] = 0; }
for (int i = 0; i < user_count; i++)
{
String timeRange = null;
switch (Integer.parseInt(list.O_TRANS_DATE[i]))
{
case 0: timeRange = "00:00 - 00:59"; break;
case 1: timeRange = "01:00 - 01:59"; break;
case 2: timeRange = "02:00 - 02:59"; break;
case 3: timeRange = "03:00 …
wild_angel 0 Newbie Poster
Before, I set combobox as editor in JTable like this code below. But it can't work like I want just like I posted the problem in my first post above.
DefaultTableModel model;
TableColumn comboboxColumn;
final JComboBox cboBarang = new JComboBox();
tabel.setModel(model);
comboboxColumn = tabel.getColumnModel().getColumn(0);
isiCboBarang(cboBarang);
comboboxColumn.setCellEditor(new DefaultCellEditor(cboBarang));
So, now I tried to use tableCellEditor, and this is my code:
tabel.setModel(model);
comboboxColumn = tabel.getColumnModel().getColumn(0);
comboboxColumn.setCellEditor(new MyComboBoxEditor());
public class MyComboBoxEditor extends JComboBox implements TableCellEditor, ItemListener {
Vector editorListeners;
public MyComboBoxEditor() {
super();
editorListeners = new Vector();
System.out.println(listItem);
for(int i =0; i < listItem.size(); i++){
addItem(listItem.get(i));
}
addItemListener(this);
}
public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) {
// Select the current value
setSelectedItem(value);
return this;
}
public Object getCellEditorValue() {
return this.getSelectedItem();
}
public boolean isCellEditable(EventObject anEvent) {
return true;
}
public boolean shouldSelectCell(EventObject anEvent) {
return true;
}
public boolean stopCellEditing() {
return true;
}
public void cancelCellEditing() {
}
public void addCellEditorListener(CellEditorListener l) {
editorListeners.add(l);
}
public void removeCellEditorListener(CellEditorListener l) {
editorListeners.remove(l);
}
public void itemStateChanged(ItemEvent e) {
if(e.getStateChange()==ItemEvent.DESELECTED)
{
Statement stmt;
ResultSet rs;
try {
//generate code
sql = "SELECT desc_bar FROM inv_item WHERE kode_bar = '" +
this.getSelectedItem() + "'";
stmt = Koneksi.getConnection().createStatement();
rs = stmt.executeQuery(sql);
if (rs.last()){
tabel.setValueAt(rs.getString(1), tabel.getSelectedRow(), 1);
} else {
tabel.setValueAt("", tabel.getSelectedRow(), 1);
}
rs.close();
stmt.close();
} catch (SQLException ex) {
Logger.getLogger(TrPOEntry.class.getName()).log(Level.SEVERE, null, ex);
}
}
}
}
With this method, it's running but not properly. For example, combobox's data are: "A", "B", "C". When I choose "A" …
wild_angel 0 Newbie Poster
Hi padtes, thx for your reply! :)
From I know, when you getString from resultSet and using an index, it begins from 1 (also I already tried from 0 and it got an error).
I tried this code in actionPerformed comboBox:
if (rs.last()==false){
tabel.setValueAt(rs.getString(1), [B]tabel.getSelectedRow()[/B], 1)
// the problem is from the bold letters
} else {
tabel.setValueAt("", tabel.getSelectedRow(), 1);
}
But it showed an error: index out of bound. I think it's because before I click the table, actionPerformed in comboBox run first. So, any idea how to do it? Thx.
wild_angel 0 Newbie Poster
Hi padtes, thx for your reply! :)
From I know, when you getString from resultSet and using an index, it begins from 1 (also I already tried from 0 and it got an error).
I tried this code in actionPerformed comboBox:
if (rs.last()==false){
tabel.setValueAt(rs.getString(1), [B]tabel.getSelectedRow()[/B], 1)
// the problem is from the bold letters
} else {
tabel.setValueAt("", tabel.getSelectedRow(), 1);
}
But it showed an error: index out of bound. I think it's because before I click the table, actionPerformed in comboBox run first. So, any idea how to do it? Thx.
wild_angel 0 Newbie Poster
I already searched anywhere but still couldn't find the solution. Or maybe the right event for what I want is not actionPerformed?
Is there anyone can help me? I'm still stuck here. Thanx
wild_angel 0 Newbie Poster
Hi All! I have a table that there is a combo box inside the table. For example, the combo box consist of item codes. And then, whenever user choose item from combo box, the next column inside the table will show name of the item. Here is my example coding:
sql = "SELECT desc_bar FROM inv_item WHERE kode_bar = '" + cboBarang.getSelectedItem().toString() + "'";
stmt = Koneksi.getConnection().createStatement();
rs = stmt.executeQuery(sql);
if (rs.last()){
tabel.setValueAt(rs.getString(1), 0, 1);
} else {
tabel.setValueAt("", 0, 1);
}
My question is how if there is many rows in a table. I tried to use this, tabel.setValueAt(rs.getString(1), tabel.getSelectedRow(), 1).
But it showed me an error, which is: index out of bound. So, how to do this ( I hope you'll understand what I'm trying to do here because my english isn't good enough :$)? Can you help me? Thx before. :)
wild_angel 0 Newbie Poster
hmm..I used DSN that I already created in ODBC (control panel-administrative tools-data sources(ODBC)). So, when I want to connect database with CR, I just picked ODBC DSN I created.
wild_angel 0 Newbie Poster
Hi, I already tried to put my code higher, but it's stil not working. I wonder if it has something to with the connection? I used DNS for data source when I set connection in Crystal Report. But I didn't use DNS in VB. Is it related or not? Ahh..I still can't figure it out. :( Can somebody help me pliz? Is there something wrong with the coding?
wild_angel 0 Newbie Poster
what do you mean by higher? oh..did I should set the cr to the database before setLogOnInfo? I will try it then and give an update later. Thx for your reply. Hope it will work. :)
wild_angel 0 Newbie Poster
I have a problem when I ran report from vb6. I use Crystal Report 8.5 as reporting tools and MySql as database for my program. When I tried to run the report in Crystal Report, it worked. But when I ran it from vb6, it showed an error: "Server has not yet been opened". Here is my codes for showing the report. Can anyone help me pliz to find the solution for my problem. Thx before.
Dim formlap1 As New lap_pembelian_barang
Dim crystal1 As CRAXDRT.Application
Dim dbTable As CRAXDDRT.DatabaseTable
Dim Report1 As CRAXDRT.Report
Dim SubReport As CRAXDRT.Report
Dim Sections As CRAXDRT.Sections
Dim Section As CRAXDRT.Section
Dim RepObjs As CRAXDRT.ReportObjects
Dim SubReportObj As CRAXDRT.SubreportObject
Dim n As Integer
Dim i As Integer
Dim j As Integer
formlap1.CRViewer1.DisplayBorder = False
formlap1.CRViewer1.DisplayTabs = False
formlap1.CRViewer1.EnableDrillDown = False
formlap1.CRViewer1.EnableRefreshButton = False
Set crystal1 = New CRAXDRT.Application
Set Report1 = crystal1.OpenReport(App.Path & "\laporan\pembelian_per_barang.rpt")
For n = 1 To Report1.Database.Tables.Count
Report1.Database.Tables(n).SetLogOnInfo "localhost", "database", user, pass
Next n
Set Sections = Report1.Sections
For n = 1 To Sections.Count
Set Section = Sections.Item(n)
Set RepObjs = Section.ReportObjects
For i = 1 To RepObjs.Count
If RepObjs.Item(i).Kind = crSubreportObject Then
Set SubReportObj = RepObjs.Item(i)
Set SubReport = SubReportObj.OpenSubreport
For j = 1 To SubReport.Database.Tables.Count
SubReport.Database.Tables(j).SetLogOnInfo "localhost", "database", user, pass
Next j
End If
Next i
Next n
Report1.DiscardSavedData
Report1.Database.SetDataSource rs
Report1.RecordSelectionFormula = "{faktur_pembelian_header.tgl_faktur}>= #" & DTPickerawal.Value & "# and {faktur_pembelian_header.tgl_faktur}<= #" & DTPickerakhir.Value & "#"
formlap1.CRViewer1.ReportSource = Report1
formlap1.CRViewer1.ViewReport
formlap1.Show
Unload Me
wild_angel 0 Newbie Poster
Thx for your reply! :)
Finally, the problem has been solved. Here is the code I used to get data from the table (in case anybody has the same problem..or maybe not.. ^^"):
tableName.getValueAt(row, column).toString()
wild_angel 0 Newbie Poster
I have 2 buttons in my form. The first button to fill the JTable from .xls file and the second button to save the content of the table to database (MySql). I haven't figure out yet the way to save data from JTable to MySql. :confused: So, can anybody help me pliz? Thanx before.