onsir 0 Light Poster

i have code like this
in page1.jsp

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<html xmlns="http://www.w3.org/1999/xhtml">

    <body>
        <h1>Test</h1>

        <script language="javascript">
            function JSGetSelectedItem() {
                var dropdownIndex = document.getElementById('lang').selectedIndex;
                var dropdownValue = document.getElementById('lang')[dropdownIndex].text;
                alert("Hello JSCript " + dropdownValue);
            }

        </script>

        <!-- to fill combobox i had get from database -->   

        <form method="post" action="page1.jsp"> >
            Please select
            <select name="lang" onChange="JSGetSelectedItem()">
                <c:forEach var="v_Init" items="${ma_Init}">
                    <option value="scem">${v_Init.schem}</option>
                </c:forEach>
            </select>
        </form>

        <a href="page2.jsp?lang="<%=request.getParameter("lang")%> >Your Select</a>

    </body>
</html>

in page2.jsp

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
   "http://www.w3.org/TR/html4/loose.dtd">

<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>Page 2</title>
    </head>
    <body>

     <%
      String selectedValue=request.getParameter("lang");
      out.println("Selected Value is : "+selectedValue);
     %>

    </body>
</html>

thanks

onsir 0 Light Poster

I made application web using hibernate + spring + velocity and
IDE Netbeans 6.8 + Glassfish

this my files

applicationContext.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:p="http://www.springframework.org/schema/p"
       xmlns:aop="http://www.springframework.org/schema/aop"
       xmlns:context="http://www.springframework.org/schema/context"
       xmlns:jee="http://www.springframework.org/schema/jee"
       xmlns:tx="http://www.springframework.org/schema/tx"
       xsi:schemaLocation="http://www.springframework.org/schema/beans
                           http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
                           http://www.springframework.org/schema/aop
                           http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
                           http://www.springframework.org/schema/tx
                           http://www.springframework.org/schema/tx/spring-tx-2.5.xsd
                           http://www.springframework.org/schema/context
                           http://www.springframework.org/schema/context/spring-context-2.5.xsd
                           http://www.springframework.org/schema/jee
                           http://www.springframework.org/schema/jee/spring-jee-2.5.xsd"
                        >

    <bean id="propertyConfigurer"
          class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"
          p:location="/WEB-INF/jdbc.properties" />

    <context:annotation-config/>
    <context:component-scan base-package="tutorial.spring"/> 
    <tx:annotation-driven/> 

    <bean id="dataSource"
          class="org.springframework.jdbc.datasource.DriverManagerDataSource"
          p:driverClassName="${jdbc.driver}"
          p:url="${jdbc.url}"
          p:username="${jdbc.username}"
          p:password="${jdbc.password}"
          />

    <bean id="sessionFactory"
          class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean"
          p:dataSource-ref="dataSource"
          p:configLocation="/WEB-INF/hibernate.cfg.xml"
          p:configurationClass="org.hibernate.cfg.AnnotationConfiguration"
          />

    <bean id="transactionManager"
          class="org.springframework.orm.hibernate3.HibernateTransactionManager"
          p:sessionFactory-ref="sessionFactory"
          />
   
</beans>

tutorial-servlet.xml

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:p="http://www.springframework.org/schema/p"
       xmlns:aop="http://www.springframework.org/schema/aop"
       xmlns:tx="http://www.springframework.org/schema/tx"
       xmlns:context="http://www.springframework.org/schema/context"
       xsi:schemaLocation="http://www.springframework.org/schema/beans
                           http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
                           http://www.springframework.org/schema/aop
                           http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
                           http://www.springframework.org/schema/tx
                           http://www.springframework.org/schema/tx/spring-tx-2.5.xsd
                           http://www.springframework.org/schema/context
                           http://www.springframework.org/schema/context/spring-context-2.5.xsd"
                           >
    
    <bean class="org.springframework.web.servlet.mvc.support.ControllerClassNameHandlerMapping"/>
    <context:component-scan base-package="tutorial.spring.ui.springmvc" />
    <bean id="messageSource"
		class="org.springframework.context.support.ResourceBundleMessageSource"
		p:basename="messages" />

    <bean id="velocityConfig"
		class="org.springframework.web.servlet.view.velocity.VelocityConfigurer">
        <property name="resourceLoaderPath"
                 value="/WEB-INF/templates/velocity/"/>
    </bean>

    <bean id="viewResolver"
		class="org.springframework.web.servlet.view.velocity.VelocityViewResolver">
        <property name="cache" value="true" />
        <property name="prefix" value="/WEB-INF/templates/velocity" />
        <property name="suffix" value=".html" />
    </bean>

</beans>

UserDao.java

package tutorial.spring.dao;
import java.util.List;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.stereotype.Repository;
import tutorial.spring.base.dao.hibernate.BaseDaoHibernate;
import tutorial.spring.model.User;

@Repository
public class UserDao extends BaseDaoHibernate<User> {

    private static final Log LOG = LogFactory.getLog(UserDao.class);

    public List<User> getAllUser() {
        return sessionFactory.getCurrentSession().createQuery("from User ").list();
    }
}

MasterService.java

package tutorial.spring.service;
import java.util.Date;
import java.util.List;
import tutorial.spring.model.User;

/**
 *
 * @author user
 */
public interface …
onsir 0 Light Poster

while i click date i want to get that date.
i have used this method but i can't to get data is clicked

i used JCalendar

public Employee() {
        super("", true, true, true, true);
        setSize(50, 50);
        initComponents();
    
 jdcDateBirth.addMouseListener(new MouseListener(){
             public void actionPerformed(ActionEvent e){
                 System.out.println("is birth " + jdcDateBirth.getDate() );

             }

            public void mouseClicked(MouseEvent e) {
                 System.out.println("is birth " + jdcDateBirth.getDate() );
            }

            public void mousePressed(MouseEvent e) {
                 System.out.println("is birth " + jdcDateBirth.getDate() );
            }

            public void mouseReleased(MouseEvent e) {
                 System.out.println("is birth " + jdcDateBirth.getDate() );
            }

            public void mouseEntered(MouseEvent e) {
                 System.out.println("is birth " + jdcDateBirth.getDate() );
            }

            public void mouseExited(MouseEvent e) {
                 System.out.println("is birth " + jdcDateBirth.getDate() );

            }
         });

}

thanks

onsir 0 Light Poster

I want to get data sales item, its with compare table item with table sale

although item in table sale nothing, data will show
according with data item

i have SQL like this

select i.code,s.date_sale
from Item i 
left join(select * from Sale where date_sale <='2009-01-31') s
       on i.code=s.code;
table Item
Id         Code         Description
1          I001          TV  
2          I002          Radio 
3          I003          Ball
4          I004          Cycle

table Sale

Id_Sale      Code     date_sale      Qty    Amount
87             I001      2009-1-3        4     7000
88             I002      2009-1-4        5     4000

i want show like this

Code      date_sale      Qty    Amount
I001      2009-1-3        4     7000
I002      2009-1-4        5     4000
I003      null                null  null
I004      null                null  null

how convert to HQL
Thanks

onsir 0 Light Poster

I have design report with ireport, if that report i run in netbeans its ok,
but while i move to drive c: got error like this

"error displaying report page. see the console for details"

if i try in command prompt get message

java.lang.NullPointerException
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
at net.sf.jasperreports.engine.util.JRClassLoader.loadClassForRealName(J
RClassLoader.java:161)
at net.sf.jasperreports.engine.util.JRClassLoader.loadClassForName(JRCla
ssLoader.java:119)
at net.sf.jasperreports.engine.export.ExporterFilterFactoryUtil.getFilte
rFactory(ExporterFilterFactoryUtil.java:56)
at net.sf.jasperreports.engine.JRAbstractExporter.createFilter(JRAbstrac
tExporter.java:1071)
at net.sf.jasperreports.engine.export.JRGraphics2DExporter.exportReport(
JRGraphics2DExporter.java:121)
at net.sf.jasperreports.view.JRViewer.paintPage(JRViewer.java:1993)
at net.sf.jasperreports.view.JRViewer$PageRenderer.paintComponent(JRView
er.java:2134)
at javax.swing.JComponent.paint(Unknown Source)
at javax.swing.JComponent.paintChildren(Unknown Source)
at javax.swing.JComponent.paint(Unknown Source)
at javax.swing.JComponent.paintChildren(Unknown Source)
at javax.swing.JComponent.paint(Unknown Source)
at javax.swing.JComponent.paintChildren(Unknown Source)
at javax.swing.JComponent.paint(Unknown Source)
at javax.swing.JComponent.paintChildren(Unknown Source)
at javax.swing.JComponent.paint(Unknown Source)
at javax.swing.JViewport.paint(Unknown Source)
at javax.swing.JComponent.paintChildren(Unknown Source)
at javax.swing.JComponent.paint(Unknown Source)
at javax.swing.JComponent.paintChildren(Unknown Source)
at javax.swing.JComponent.paint(Unknown Source)
at javax.swing.JComponent.paintChildren(Unknown Source)
at javax.swing.JComponent.paint(Unknown Source)
at javax.swing.JComponent.paintChildren(Unknown Source)
at javax.swing.JComponent.paint(Unknown Source)
at javax.swing.JComponent.paintChildren(Unknown Source)
at javax.swing.JComponent.paint(Unknown Source)
at javax.swing.JComponent.paintChildren(Unknown Source)
at javax.swing.JComponent.paint(Unknown Source)
at javax.swing.JLayeredPane.paint(Unknown Source)
at javax.swing.JComponent.paintChildren(Unknown Source)
at javax.swing.JComponent.paintToOffscreen(Unknown Source)
at javax.swing.BufferStrategyPaintManager.paint(Unknown Source)
at javax.swing.RepaintManager.paint(Unknown Source)
at javax.swing.JComponent.paint(Unknown Source)
at java.awt.GraphicsCallback$PaintCallback.run(Unknown Source)
at sun.awt.SunGraphicsCallback.runOneComponent(Unknown Source)
at sun.awt.SunGraphicsCallback.runComponents(Unknown Source)
at java.awt.Container.paint(Unknown Source)
at javax.swing.RepaintManager.paintDirtyRegions(Unknown Source)
at javax.swing.RepaintManager.paintDirtyRegions(Unknown Source)
at javax.swing.RepaintManager.seqPaintDirtyRegions(Unknown Source)
at javax.swing.SystemEventQueueUtilities$ComponentWorkRequest.run(Unknow
n Source)
at java.awt.event.InvocationEvent.dispatch(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
2009-05-19 15:48:03,359 [AWT-EventQueue-0] INFO org.hibernate.impl.SessionFacto
ryImpl closing
2009-05-19 15:48:03,359 [AWT-EventQueue-0] INFO org.hibernate.connection.Driver
ManagerConnectionProvider cleaning up connection pool: jdbc:mysql://localhost/a1
2s

this my code

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import mst.common.CommonUtility;
import mst.hrd.hibernate.properties.HibernateConnection;
import net.sf.jasperreports.engine.*;
import net.sf.jasperreports.engine.data.JRBeanCollectionDataSource;
import net.sf.jasperreports.engine.query.JRHibernateQueryExecuterFactory;
import net.sf.jasperreports.view.*;
import org.hibernate.HibernateException; …
onsir 0 Light Poster

how to change database at runtime, i use hibernate and spring.
i have make like this

hibernate.cfg.xml

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
    <session-factory>

        <mapping class="com.model.Person" />
        <mapping class="com.model.Group" />
        
    </session-factory>
</hibernate-configuration>

spring.ctx.xml

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:p="http://www.springframework.org/schema/p"
       xmlns:context="http://www.springframework.org/schema/context"
       xmlns:tx="http://www.springframework.org/schema/tx"
       xsi:schemaLocation="
       http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
       http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd
       http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd">
    

    <context:property-placeholder location="classpath:jdbc.properties">
    <context:component-scan base-package="com.hbtemplate" />
    <tx:annotation-driven transaction-manager="txManager" />
    
    
   <bean id="dataSource"
   class="org.springframework.jdbc.datasource.DriverManagerDataSource"
   p:driverClassName="${hibernate.connection.driver_class}"
   p:url="${hibernate.connection.url}"
   p:username="${hibernate.connection.username}"
   p:password="${hibernate.connection.password}" />

  
   
   <bean id="sessionFactory"
   class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean"
   p:dataSource-ref="dataSource">
        <property name="configLocation">
            <value>classpath:hibernate.cfg.xml</value>
        </property>
        <property name="hibernateProperties">
            <props>
                <prop key="hibernate.dialect">
                    ${hibernate.dialect}
                </prop>
                <prop key="hibernate.show_sql">
                    ${hibernate.show_sql}
                </prop>
                <prop key="hibernate.generate_statistics">
                    ${hibernate.show_statistics}
                </prop>
                
                <prop key="hibernate.hbm2ddl.auto">
					${hibernate.hbm2ddl_auto}
				</prop>
            </props>
        </property>
    </bean>
    

        
    <bean id="txManager"
          class="org.springframework.orm.hibernate3.HibernateTransactionManager"
          p:sessionFactory-ref="sessionFactory" />
              
            </beans>

file hibernate.cfg.xml and file spring.ctx.xml i make in same folder

public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new MainFrame().setVisible(true);
               
            String PROP_FILE = "jdbc.properties";
            Properties p = new Properties();
          
            p.setProperty("hibernate.connection.driver_class","com.mysql.jdbc.Driver");
            p.setProperty("hibernate.connection.url","jdbc:mysql://localhost/changeAtRuntime");
            p.setProperty("hibernate.connection.username","root");
            p.setProperty("hibernate.connection.password","");
            p.setProperty("hibernate.dialect","org.hibernate.dialect.MySQLInnoDBDialect");
            p.setProperty("hibernate.hbm2ddl_auto","create");
            p.setProperty("hibernate.show_sql","true");
            p.setProperty("hibernate.show_statistics","true");

            //save properties
            FileOutputStream out = null;
            try {
                out = new FileOutputStream(PROP_FILE);
                    
        } catch (FileNotFoundException ex) {
                  ex.printStackTrace();
        } finally {
            try {
                out.close();
            } catch (IOException ex) {
               
            }
        }



        //load file properties
        p = new Properties();
            try {
            FileInputStream in = new FileInputStream(PROP_FILE);
            p.load(in);
            in.close();

        } catch (IOException i) {
                i.printStackTrace();
        }


        applicationContext = new ClassPathXmlApplicationContext("spring.ctx.xml");

        }
        });
    }

get error

INFO: Loading properties file from class path resource …
onsir 0 Light Poster

Hi, all

How to create report use IReport and Hibernate
I have tried, like this :
:

1. create file hibernate.cfg.xml

xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<property name="connection.url">jdbc:mysql://localhost/a6</property>
<property name="connection.username">root</property>
<property name="connection.driver_class">com.mysql.jdbc.Driver</property>
<property name="dialect">org.hibernate.dialect.MySQLDialect</property>
<property name="connection.password"></property>
<property name="transaction.factory_class">org.hibernate.transaction.JDBCTransactionFactory</property>
<!-- thread is the short name for
org.hibernate.context.ThreadLocalSessionContext
and let Hibernate bind the session automatically to the thread
-->
<property name="current_session_context_class">thread</property>
<!-- this will show us all sql statements -->
<property name="hibernate.show_sql">true</property>

<!-- mapping files -->
<mapping resource="mst/hrd/model/hibernate/hbmxml/T_Karyawan_Ms.hbm.xml"/> 

</session-factory>
</hibernate-configuration>

2. create file T_Karyawan_Ms.java

package mst.hrd.model.hibernate.hbmxml;

import java.io.Serializable;
import java.util.Date;

public class T_Karyawan_Ms implements Serializable{
private String kodePt;
private String karyawanId;
private String namaKaryawan;

public T_Karyawan_Ms() {

}

public String getKodePt() {
return kodePt;
}

public void setKodePt(String kodePt) {
this.kodePt = kodePt;
}

public String getKaryawanId() {
return karyawanId;
}

public void setKaryawanId(String karyawanId) {
this.karyawanId = karyawanId;
}

public String getNamaKaryawan() {
return namaKaryawan;
}

public void setNamaKaryawan(String namaKaryawan) {
this.namaKaryawan = namaKaryawan;
}


}

3. create file T_Karyawan_Ms.hbm.xml

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">

<hibernate-mapping package="mst.hrd.model.hibernate.hbmxml">
<class name="T_Karyawan_Ms" table="t_karyawan_ms">

<composite-id>
<key-property name="kodePt" type="string" column="KODE_PT" />
<key-property name="karyawanId" type="string" column="KARYAWAN_ID"/>
</composite-id>

<property name="namaKaryawan" type="string" column="NAMA_KARYAWAN"/>
</class>

</hibernate-mapping>

4. create HibernateProperties.java

public static void hibernateProperties(String typeDb){
CVariable var = new CVariable(); 
String user=var.getUserMst();
String pwd=var.getPwdMst();

configuration = new Configuration()
.addClass(mst.hrd.model.hibernate.hbmxml.T_Karyawan_Ms.class) 
.setProperty("hibernate.dialect","org.hibernate.dialect.MySQLInnoDBDialect")
.setProperty("hibernate.connection.driver_class", "com.mysql.jdbc.Driver")
.setProperty("hibernate.connection.url", "jdbc:mysql://"+var.host+ "/"+var.dbGlobal+"")
.setProperty("hibernate.connection.username", user)
.setProperty("hibernate.connection.password", pwd);
}

In iReport I used step …

onsir 0 Light Poster

how to connet to database using hibernate, because i create hibernate.cfg.xml while is running
i have build simple application for test connection to database using hibernate.
when write application i'm not write hibernate.cfg.xml, but i want create while running.
so when i click button show error like this

"
"Jun 9, 2008 8:59:19 AM org.hibernate.cfg.Environment <clinit>
INFO: Hibernate 3.2.1
Jun 9, 2008 8:59:19 AM org.hibernate.cfg.Environment <clinit>
INFO: hibernate.properties not found
Jun 9, 2008 8:59:19 AM org.hibernate.cfg.Environment buildBytecodeProvider
INFO: Bytecode provider name : cglib
Jun 9, 2008 8:59:19 AM org.hibernate.cfg.Environment <clinit>
INFO: using JDK 1.4 java.sql.Timestamp handling
Jun 9, 2008 8:59:19 AM org.hibernate.cfg.Configuration configure
INFO: configuring from resource: /hibernate.cfg.xml
Jun 9, 2008 8:59:19 AM org.hibernate.cfg.Configuration getConfigurationInputStream
INFO: Configuration resource: /hibernate.cfg.xml
error connected /hibernate.cfg.xml not found
"

this my code

private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
    Session session = null;
    try{
        SessionFactory sessionFactory = new Configuration().configure().buildSessionFactory();
        session =sessionFactory.openSession();
        Object[] options = {"Yes"};
        int n = JOptionPane.showOptionDialog(null, "connect success","test",JOptionPane.YES_NO_OPTION,JOptionPane.QUESTION_MESSAGE,null, options,options[0]);

    }catch(Exception e){
      System.out.println("error connected "+ e.getMessage());
      Object[] options = {"Yes"};
      int n = JOptionPane.showOptionDialog(null, "error connected\n"+ e,"test",JOptionPane.YES_NO_OPTION,JOptionPane.QUESTION_MESSAGE,null, options,options[0]);
      }
    }

this file hibernate.cfg.xml i create while running

<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">

<hibernate-configuration>
<session-factory>
      <property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
      <property name="hibernate.connection.url">jdbc:mysql://localhost/hibernatetutorial</property>
      <property name="hibernate.connection.username">root</property>
      <property name="hibernate.connection.password"></property>
      <property name="hibernate.connection.pool_size">10</property>
      <property name="show_sql">true</property>
      <property name="dialect">org.hibernate.dialect.MySQLDialect</property>
      <property name="hibernate.hbm2ddl.auto">update</property>
</session-factory>
</hibernate-configuration>

because i want make connection more flexible using hibernate, who user can connect to other database or server.
thx

onsir 0 Light Poster

is true new me learn hibernate. do you know tutorial is best for learn about properties file.
thanks.

onsir 0 Light Poster

Hi, all
How to make connection to database more dynamically using hibernate.

Example while my application running, I want to change connection to other server and database name but structure database is still same.

I using jdbc I commonly using code like this

public static void getConnection(){
   try { Class.forName("com.mysql.jdbc.Driver").newInstance() ;
           con=null;
        con=DriverManager.getConnection("jdbc:mysql://"+MainMenu.serverName+
"/" +
                                                      
    MainMenu.dbName + "?user=root&password=root");
            
           } catch (Exception e){
                                  System.out.println(e); 
                                 }
 }

Then if connection to database using file .properties or .xml like this how to make ?

File jdbc.properties

jdbc.username=root
jdbc.password=root
jdbc.url=jdbc:mysql://localhost/mydb1
jdbc.driver=com.mysql.jdbc.Driver

or file hibernate.cfg.xml

<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
          "-//Hibernate/Hibernate Configuration DTD
3.0//EN"
         
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
	<property
name="connection.url">jdbc:mysql://localhost/mydb1</property>
	<property name="connection.username">root</property>
	<property
name="connection.driver_class">com.mysql.jdbc.Driver</property>
	<property
name="dialect">org.hibernate.dialect.MySQLDialect</property>
	<property name="connection.password"></property>
 <property
name="transaction.factory_class">org.hibernate.transaction.JDBCTransactionFactory</property>

thanks a lot.

onsir 0 Light Poster

What is i must config java. I'm using java jdk_1.6 update 3 with netbeans 6.0
while i intsall java i used jdk-6u3-nb_0-linux.sh
thanks

onsir 0 Light Poster

how to take computer name in linux
I had tried this code in Windows Xp, it's Ok. but while i run in linux i got error
"Cannot get computer name java.net.UnknownHostException: comcentos: comcentos"

i'm using Centos 5.

i have edit in file etc/sysconfig/network
NETWORKING=yes
NETWORKING_IPV6=yes
HOSTNAME=comcentos

package myPackage;
import java.io.* ;
import java.net.* ;

public class ComputerName {

public static void main ( String[] args ) {

//To get the computer name
try {
String computerName = InetAddress.getLocalHost( ).getHostName ();
System.out.println ( "Computer Name: " + computerName ) ;
}
catch ( Exception e ) {
System.out.println ( " Cannot get computer name " + e ) ;
}
}
}

thanks all for your help

onsir 0 Light Poster

hi,
help me, how to make limit input only two decimal, i used jformattedtext.
example : if i input more than two decimal in jformattedtext, then it can't and automatically delete by backspace.

thanks for your help.

onsir 0 Light Poster

hi all,
how to detect program is running in my computer.
etc: i have open my program application name is myProgApp, in computer jhon, so if i open again the program that in computer jhon will show message 'file already open' .
thanks, for your help.

onsir 0 Light Poster

Hi,
how to create trigger in mysql 5 with java.
i have code like this, but still error "
java.sql.SQLException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'DELIMITER $$ CREATE TRIGGER `a1`.`xData` AFTER UPDATE ON `a1`.`tinfo`IF (' at line 1 "
thanks.

SQL="";
 SQL="DELIMITER $$ "+
     "DROP TRIGGER   `a1`.`xData` || "+
     "CREATE TRIGGER `a1`.`xData` AFTER UPDATE ON `a1`.`tinfo`" +
     "FOR EACH ROW BEGIN " +
     "IF (OLD.Name <> NEW.Name) THEN " +
     "INSERT INTO tlog (remark) VALUES ('EditData'); " +
     "END IF; " +
     "END;" +
     "$$" +
     "DELIMITER;";
 stmt=con.createStatement();
 rs=stmt.execute(SQL);
onsir 0 Light Poster

please give me a link, thanks.

onsir 0 Light Poster

hello
how to convert string to double, and result is string.
example ;
String code =00000000001;
Double plus =code + 1;
String result =plus; // and result is 0000000002

thanks

onsir 0 Light Poster

i have tried, but still error or data can't display in jtable

// NewJFrame.java
package newpackage;

import ca.odell.glazedlists.BasicEventList;
import ca.odell.glazedlists.EventList;
import ca.odell.glazedlists.FilterList;
import ca.odell.glazedlists.SortedList;
import ca.odell.glazedlists.TextFilterator;
import ca.odell.glazedlists.gui.TableFormat;
import ca.odell.glazedlists.swing.EventTableModel;
import ca.odell.glazedlists.swing.TextComponentMatcherEditor;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.Comparator;
import java.util.List;

public class NewJFrame extends javax.swing.JFrame {
    private static Connection c;
    private static Statement selectStatement;
    public NewJFrame() {
        initComponents();
        
       try{
        EventList<Customer> list =getCustomer();   
        SortedList<Customer> sortedList = new SortedList<Customer>(list, new CustomerComparator());
        FilterList filterList = new FilterList(sortedList, new TextComponentMatcherEditor(txtFilter,new CustomerFilter()));      
        EventTableModel model = new EventTableModel(filterList, new CustomerTableFormat());
        tblCustomer.setModel(model);
       }catch (Exception e){e.printStackTrace();}
        
    }
    
  public  class Customer {
    private String code, name;
    
    public String getCode() {
        return code;
    }
    
    public void setCode(String code) {
        this.code = code;
    }
    
    public String getName() {
        return name;
    }
    
    public void setName(String name) {
        this.name = name;
    }
    
    
    public String toString() {
        return getCode() + " " + getName();
    }
 }
    
    
class CustomerComparator implements Comparator{
    public int compare(Object a, Object b) {
        Customer cusA = (Customer) a;
        Customer cusB = (Customer) b;
         
        if(a.toString().equals(b.toString()))
            return 0;
            return cusA.getCode().compareTo(cusB.getCode());
    }
    
}


class CustomerFilter implements TextFilterator{
 public void getFilterStrings(List baseList, Object element) {
        Customer customer = (Customer) element;
        baseList.add(customer.getCode());
        baseList.add(customer.getName());
	}
}

    
public class CustomerTableFormat implements TableFormat{
    public int getColumnCount() { 
        return 2; 
    }
    
    public String getColumnName(int column) {
        switch(column){
            case 0: return "Code";
            case 1: return "Name";
            default: return "";
        }
    }
    
    public Object getColumnValue(Object baseObject,int column) {
        Customer customer = (Customer) baseObject;
        switch(column){
            case 0: return customer.getCode();
            case 1: return customer.getName();
            default: return "";
        } …
onsir 0 Light Poster

hai , all
This coding about filter data using jTextFiled and display in jtable, so help me to combine these class be one class.
thanks

//DBAccess.java
import ca.odell.glazedlists.BasicEventList;
import ca.odell.glazedlists.EventList;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

public class DBAccess {
    private static Connection c;
    private static Statement selectStatement;
    static{
    try{
        Class.forName("com.mysql.jdbc.Driver");
        c = DriverManager.getConnection("jdbc:mysql://localhost/MyDB","root","");
            selectStatement = c.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_READ_ONLY);
        } catch(ClassNotFoundException e){            		
            e.printStackTrace();
        } catch(SQLException e){ 
            e.printStackTrace(); 
        }   
   }

    public static EventList<Customer> getCustomer ()throws SQLException{
        EventList<Customer> list = new BasicEventList<Customer>();
        ResultSet rs = selectStatement.executeQuery("select * from customers");
        while(rs.next()){
            list.add(getCustomer(rs));
        }
        return list;
    }

    
    public static Customer getCustomer(ResultSet rs)throws SQLException{
        Customer customer = new Customer();
        customer.setCode(rs.getString(1));
        customer.setName(rs.getString(2));
        return customer 
   }
 }


//Customer.java
package newpackage;
public class Customer {
    private String code, name;
    public Customer () {}
    
    public String getCode() {
        return code; 
    }
    
    public void setCode(String code) {
        this.code = code; 
    }
    
    public String getName() {
        return name;
    }
    
    public void setName(String name) {
        this.name = name;
    }
    
    public String toString() {
        return getCode() + " " + getName();
    }
 }

//CustomerComparator.java
package newpackage;
import java.util.Comparator;
public class CustomerComparator implements Comparator{
   
public CustomerComparator() {}
 public int compare(Object a, Object b) {
        Customer cusA = (Customer) a;
        Customer cusB = (Customer) b;
        if(a.toString().equals(b.toString()))
            return 0;
            return cusA.getCode().compareTo(cusB.getCode());
    }
}
    
//CustomerFilter.java
package newpackage;
import ca.odell.glazedlists.TextFilterator;
import java.util.List;
import newpackage.Customer;
public class CustomerFilter implements TextFilterator{
    public CustomerFilter() { }
    public void getFilterStrings(List baseList, Object element) {
        Customer customer = (Customer) element;
        baseList.add(customer.getCode());
        baseList.add(customer.getName());
	}
}


//CustomerTableFormat.java
package newpackage; …
onsir 0 Light Poster

Ok, its has worked, but how to make clear selection if some node hase checked.
i have code
for(int i=0; i<jTree1.getRowCount(); i++){
jTree1.expandRow(i);
jTree1.clearSelection();
}
but not result.

thanks

onsir 0 Light Poster

hi, all

how to using swing component jtree with jcheckbox in netbeans 5.5
i have got code from this link
http://www.jroller.com/santhosh/date/20050610, but i can't combine with my project

i hope somebody give me solution for my problem.

thanks.

onsir 0 Light Poster

" Don't generate key upon every request, keep it a constant. "

how make it , where is i put and how i get key for value key variable?

onsir 0 Light Poster

Hi, all

I have code like this for encrypt - decrypt. but every time i run, result encrypt always different.
so how to value in varible key constant.
then result same every time run

thanks.

import java.io.*;
> import java.security. *;
> import javax.crypto. *;
> import sun.misc.*;
> import com.sun.crypto. provider. *;
> public class SecretWriting {
> public static void main(String[ ] args) throws
> Exception {
> Key key;
> KeyGenerator generator =
> KeyGenerator. getInstance( "DES");
>
> key = generator.generateK ey();
>
> Cipher cipher =
> Cipher.getInstance( "DES/ECB/ PKCS5Padding" );
> cipher.init( Cipher.ENCRYPT_ MODE,key) ;
>
> String amalgam = "ABCD1234";
>
> //encrypt
> for (int i = 2; i < args.length; i++)
> amalgam += " " + args;
> byte[] stringBytes = amalgam.getBytes( "UTF8");
> byte[] raw = cipher.doFinal( stringBytes) ;
> BASE64Encoder encoder = new BASE64Encoder( );
>
> String base64 = encoder.encode( raw);
>
> //decrypt
> cipher.init( Cipher.DECRYPT_ MODE, key);
> BASE64Decoder decoder = new BASE64Decoder( );
> byte[] raw2 = decoder.decodeBuffe r(base64) ;
> byte[] stringBytes2 = cipher.doFinal( raw2);
> String result = new String(stringBytes, "UTF8");
>
> System.out.println( "Text = " + amalgam);
> System.out.println( "result encrypt = " + base64);
> System.out.println( …

onsir 0 Light Poster

Hi,

i have installed Netbean 5.0 with file jdk-1_5_0_09nb-5_0-win-ml
, but why my Netbean 5.0 IDE is not MDI Application , JFInternal Frame. while a right clik my Project

thanks.

onsir 0 Light Poster

Hello , all

how to change tab order.
example :
position cursor is now in txtCode, then while i press key tab , cursor move to other component.

thanks.

onsir 0 Light Poster

Hi, all
how to make status bar in main menu with JFrame using netbeans, and i want to show.
User : A 2007-4-12 into status bar.

thanks

onsir 0 Light Poster

help me, please....

onsir 0 Light Poster

I have install file jdk-1_5_0_09-nb-5_0-linux-ml.bin
Netbean5-5.0 i save in folder /usr/local/java/netbeans-5.0
jdk i save in folder /usr/local/java/jdk1.5.0_09

i have extract file iReport-2.0.0.tar.gz to /usr/local/iReport-2.0.0

then i copy file tools.jar on lib jdk to folder /usr/local/iReport-2.0.0/lib/tools.jar
then i run with type
[root@localhost iReport-2.0.0]# ./iReport.sh

and show error mussage like this
Exception in thread "main" java.lang.NullPointerException
at java.util.Hashtable.put(libgcj.so.7rh)
at javax.swing.plaf.basic.BasicToolBarUI.setBorderToRollover(libgcj.so.7rh)
at javax.swing.plaf.basic.BasicToolBarUI$ToolBarContListener.componentAdded(libgcj.so.7rh)
at java.awt.Container.addImpl(libgcj.so.7rh)
at javax.swing.JToolBar.addImpl(libgcj.so.7rh)
at java.awt.Container.add(libgcj.so.7rh)
at it.businesslogic.ireport.gui.ToolbarFormatPanel.initComponents(ToolbarFormatPanel.java:170)
at it.businesslogic.ireport.gui.ToolbarFormatPanel.<init>(ToolbarFormatPanel.java:57)
at it.businesslogic.ireport.gui.MainFrame.<init>(MainFrame.java:486)
at it.businesslogic.ireport.gui.MainFrame.main(MainFrame.java:8016)

then i try to edit file iReport.sh like this and still error
#!/bin/bash
cd $(dirname $0)/bin
./startup.sh $*
EXEDIR=${0%/*}
DIRLIBS=${EXEDIR}/../lib/*.jar
for i in ${DIRLIBS}
do
if [ -z"$IREPORT_CLASSPATH" ] ; then
IREPORT_CLASSPATH=$i else
IREPORT_CLASSPATH="$i":$IREPORT_CLASSPATH fi
done DIRLIBS=${EXEDIR}/../lib/*.zip
for i in ${DIRLIBS}do
if [ -z"$IREPORT_CLASSPATH" ] ; then
IREPORT_CLASSPATH=$i else
IREPORT_CLASSPATH="$i":$IREPORT_CLASSPATH fi done IREPORT_CLASSPATH="${EXEDIR}/../classes":"${EXEDIR}/../fonts":
$IREPORT_CLASSPATHIREPORT_HOME="${EXEDIR}/.."
LD_LIBRARY_PATH= /home/sgorini/jasper/jaspars-alpha4:/usr/share/remedy/api63/lib/
java -classpath
"$IREPORT_CLASSPATH:$CLASSPATH"

how to setting installation iReport-2.0.0 in Linux, i hope by detail.
i use Linux Centos 5.

thanks

onsir 0 Light Poster

I have download iReport-2.0.0.tar.gz. so how to install on linux centos 5 or mandriva 2007

thanks

onsir 0 Light Poster

Hi,
how to make programming for write and read text files with java and netbeans,
and that files automatically save in application folder.

thanks

onsir 0 Light Poster

where i get jasperreport and ireport for linux, and what files i must be download.
thanks

onsir 0 Light Poster

how to show data from database to treeview.
example: data like this

code Menuname l_evel parent
M01 Maintenance 2 File
M0101 Area 3 M01
M0102 Terms 3 M01
M0103 Category 3 M01
M010401 Rate Maintenance 4 M0104
M0106 Customer 3 M01
M010601 Customer Maintenance 4 M0106

please give code.

thx

onsir 0 Light Poster

so how to show in jTable

onsir 0 Light Poster

how to make code for access form in many form. and sub menu
exp: I give user can't access form Purchasing, but inventory not.
with character 10
*1 can access
*0 can't access

onsir 0 Light Poster

in Main Report I have make formula by the name of @a, then
in sub of report I make formula by the name of @b.
then I wish to make new in main report with the name @c.

where value of formul @c is @a-@b.
but formula @b in subreport,
I can't to use/ not show in main report.
how I can take formula @b which in subreport.

thank's

onsir 0 Light Poster

I have Fedora Core 6 linux install
last stepped into choice of Grub boot.
I select;choose Fedora core 6.
I edit kernel / boot / root=LABEL ro vmlinuz-2.6.18-1.2798.fc6xen=/ quite
Afterwards I follow setting of Setup Agent. After me click finish monitor life death and blank, multiply times;

So I try to restart, after booting show prompt command [localhost]: this show only 3 second, just on screen
show HZ ?

Then I try to use boot of CD by type rescue linux and me type chroot / mnt / sysimage

Then I edit file in boot/grub/grub.conf
Timeout=30
#hiddenmenu
kernel / boot / root=LABEL ro vmlinuz-2.6.18-1.2798.fc6xen=/ quite

then I save.
then I try to reboot,but just remain to come up HZ ?

how so that can use my linux?
I which must edit/instal again.
my computer: Sata HD; Memory 512; Proc P4.3.0, Foxconn MB.

Of my friends aid render thanks.

onsir 0 Light Poster

Hi,
how to using function "for" to show iteration and the result
put in jTextArea or jFrame.
exp: i want to loop value 1 to 10, then
result :
1 (iteration 1)
2 (iteration 2)
.
.
10 (iteration 10)
I'm using netbeans
Thank's

onsir 0 Light Poster

I have data in mysql database, i'm has succesful for connect, but how to show data in jTable.
help to give me example with very detail, because i'm newbie in java progamming


best regard
onsir