WebBrowser1.DocumentText

WebBrowser1.DocumentText

Re: WebBrowser1.DocumentText

Thank you for your valuable responses.

I am currently using WebBrowser control to automate a few things like auto-login a site, etc.

I don’t know what is the difference between Navigated and DocumentComplete events, plus
in my application, DocumentComplete event never fired yet… Then I used Navigated instead.
But the problem is that the document is incomplete. I’ve examined Document.body.innerHTML
and only a part of the source appears…

Java Programming – Call jasper report from java

customize JasperViewer, change Title and other tool bar

Java Programming – Call jasper report from java

Hi friends,

I amusing jasper report for reporting my application. If I call .jrxml file the report successfully added in my application but .jasper file could not be loaded. I download some sample code from one website that code also not working. Please help me. This is the sample code.

import javax.swing.*;
import java.awt.*;
import java.sql.*;
import java.util.*;
import java.io.*;

import net.sf.jasperreports.engine.*;
import net.sf.jasperreports.engine.design.*;
import net.sf.jasperreports.view.*;

public class ReportViewer extends JFrame
{

public ReportViewer(String fileName)
{
this(fileName,null);
}

public ReportViewer(String fileName,HashMap parameter)
{
super(“View Report");
try
{

Class.forName(“sun.jdbc.odbc.JdbcOdbcDriver");
Connection con = DriverManager.getConnection(“jdbc:odbc:udtsteelshop");

JasperPrint print = JasperFillManager.fillReport(fileName, parameter, con);

JRViewer viewer=new JRViewer(print);

Container c=getContentPane();
c.add(viewer);
}
catch(ClassNotFoundException cnfe)
{
cnfe.printStackTrace();
}
catch(SQLException sqle)
{
sqle.printStackTrace();
}
catch(JRException jre)
{
jre.printStackTrace();
}

setBounds(10,10,600,500);
setDefaultCloseOperation(DISPOSE_ON_CLOSE);

}

public static void main(String args[])
{

HashMap param=new HashMap();
param.put(“FromDate", “2009-07-22″);
param.put(“ToDate", “2009-07-25″);
ReportViewer viewer=new ReportViewer(“C:\\Documents and Settings\\TAINNTECH\\My Documents\\NetBeansProjects\\UdtSteelShop\\Reports\\PurchaseList.jasper",param);
viewer.setVisible(true);
}
}

Java Persistence and MS SQL IDENTITY with Trigger

IDE: NetBeans 6.5

When using JTable to bind data from MS SQL, IDENTITY column will have some problem if you write  trigger and insert another table with IDENTITY column.

Java Persistence use SELECT @@IDENTITY to get ID and update java object.

But unfortunaly, SELECT @@IDENTITY is by session, to get the actually new id you should use  SELECT IDENT_CURRENT(‘TABLENAME’).

I don’t know how to modify source code, and lazy to find. so I think a cheating code. list below:

create trigger dbo.mytable_trigger on mytable
for insert ,update, delete
as
declare @old_id int
–select @old_id = @@IDENTITY
SELECT @old_id = IDENT_CURRENT(‘mytable’)

— your code here

–end of your code

create table #t(a int identity(1,1), b int)
set @old_id = @old_id – 1
dbcc checkident(‘#t’, reseed, @old_id)
insert into #t (b) values(0)

It’s work.

SQL SERVER – @@IDENTITY vs SCOPE_IDENTITY() vs IDENT_CURRENT – Retrieve Last Inserted Identity of Record

SQL SERVER – @@IDENTITY vs SCOPE_IDENTITY() vs IDENT_CURRENT – Retrieve Last Inserted Identity of Record « Journey to SQL Authority with Pinal Dave

SELECT @@IDENTITY
It returns the last IDENTITY value produced on a connection, regardless of the table that produced the value, and regardless of the scope of the statement that produced the value.
@@IDENTITY will return the last identity value entered into a table in your current session. While @@IDENTITY is limited to the current session, it is not limited to the current scope. If you have a trigger on a table that causes an identity to be created in another table, you will get the identity that was created last, even if it was the trigger that created it.

SELECT SCOPE_IDENTITY()
It returns the last IDENTITY value produced on a connection and by a statement in the same scope, regardless of the table that produced the value.
SCOPE_IDENTITY(), like @@IDENTITY, will return the last identity value created in the current session, but it will also limit it to your current scope as well. In other words, it will return the last identity value that you explicitly created, rather than any identity that was created by a trigger or a user defined function.

SELECT IDENT_CURRENT(’tablename’)
It returns the last IDENTITY value produced in a table, regardless of the connection that created the value, and regardless of the scope of the statement that produced the value.
IDENT_CURRENT is not limited by scope and session; it is limited to a specified table. IDENT_CURRENT returns the identity value generated for a specific table in any session and any scope.

To avoid the potential problems associated with adding a trigger later on, always use SCOPE_IDENTITY() to return the identity of the recently added row in your T SQL Statement or Stored Procedure.

EJB3 – JPA – Query

low level programmer : weblog

EJB3 – JPA – Query

Description
JPA的Query是很重要又方便的東西, 不過要注意盡量不要把Query和一般的entity處理方式放一起.
因為JPA沒要求persistence provider必須將Query和persistence context同步, 所以現在就常看到一些因為使用Query導致使用者需要先flush才能Query的現象.
Reference
EJB3 in Action – CH10 – Using the query and JPQL to retrieve entities