Hi Henki,

Well u cud make a bean called DbBean.java and use the bean using the
jsp:useBean tag.
I used the following bean ...hope u find it useful

Best LUck
Jayman

//DbBean.java

package emp;

import java.sql.*;
import java.io.*;
import java.util.*;

public class DbBean
{
        String dbDriver = "postgresql.Driver";
        String dbURL;
        String dbUser;
        String dbPasswd;
        Connection dbCon;
        Statement stmt;


        public boolean connect()
                throws ClassNotFoundException, SQLException, IOException
        {
                /*Properties props = new Properties();
                String fileName = "DbBean.properties";
                FileInputStream in = new FileInputStream(fileName);
                props.load(in);*/

                dbDriver = "postgresql.Driver";//props.getProperty("jdbc.driver");
                dbURL =
"jdbc:postgresql://localhost/emp";//props.getProperty("jdbc.url");
                dbUser = "jayman";//props.getProperty("jdbc.username");
                dbPasswd = "jd";//props.getProperty("jdbc.password");

                Class.forName(dbDriver);
                dbCon = DriverManager.getConnection(dbURL, dbUser, dbPasswd);
                stmt = dbCon.createStatement();

                return true;
        }

        public void close()
                throws SQLException
        {
                stmt.close();
                dbCon.close();
        }

        public ResultSet execSQL(String sql)
                throws SQLException
        {
                ResultSet rs = stmt.executeQuery(sql);
                return rs;
        }

}



Henki Lubis wrote:
>
> Hi .. guys .. i am learning how to get data from a database and show it up
> into my web page..
> Let say i have a table called Countries and has 2 fields called CountryID
> and CountryName ..how can i get the value of CountryNAME and show it up into
> my page ?? let say i have an input type="text" ...
>
> I really apreciate for your help ..
>
> A beginner from Indonesia
>
> ===========================================================================
> To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
> Some relevant FAQs on JSP/Servlets can be found at:
>
>  http://java.sun.com/products/jsp/faq.html
>  http://www.esperanto.org.nz/jsp/jspfaq.html
>  http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
>  http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets



__________________________________________________
Do You Yahoo!?
Talk to your friends online with Yahoo! Messenger.
http://im.yahoo.com

===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
Some relevant FAQs on JSP/Servlets can be found at:

 http://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.html
 http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
 http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets

Reply via email to