sample JSP code connecting to PostgreSQL

Поиск
Список
Период
Сортировка
Искать

sample JSP code connecting to PostgreSQL

От:
Roj Niyogi <niyogi@pghoster.com>
Дата:
Hi folks,

I'm wondering if anybody would be pleasant enough to give me a complete 
script containing JSP code that makes a simple connection to a 
PostgreSQL database, retrieves data and dumps to screen.

I must be dumb not to be able to find this information anywhere on the 
net. :(

Regards,
Roj

-- 
niyogi@pghoster.com

pgHoster - PostgreSQL Web Hosting & Consulting
www.pghoster.com



Re: sample JSP code connecting to PostgreSQL

От:
Tony Grant <tony@tgds.net>
Дата:
On Mon, 2003-02-24 at 02:50, Roj Niyogi wrote:

> I'm wondering if anybody would be pleasant enough to give me a complete 
> script containing JSP code that makes a simple connection to a 
> PostgreSQL database, retrieves data and dumps to screen.
> 
> I must be dumb not to be able to find this information anywhere on the 
> net. :(

I just use Dreamweaver MX. 

Or you can build your JSP in NetBeans / SunOne Studio which are free
tools.

Cheers

Tony Grant

-- 
www.tgds.net Library management software toolkit, 
redhat linux on Sony Vaio C1XD, 
Dreamweaver MX with Tomcat and PostgreSQL

Re: sample JSP code connecting to PostgreSQL

От:
Andres Ledesma <aledes@telefonica.net>
Дата:
On Monday 24 February 2003 08:50, you wrote:
> Hi folks,
>
> I'm wondering if anybody would be pleasant enough to give me a complete
> script containing JSP code that makes a simple connection to a
> PostgreSQL database, retrieves data and dumps to screen.
>
> I must be dumb not to be able to find this information anywhere on the
> net. :(
>
> Regards,
> Roj

Hope this help ...to you or anybody else.. 

Best regards, 

Andrewle

import java.sql.*;

class gettablerows{

    public static void main(String args[]) 
    {


		String url = "jdbc:postgresql://localhost/database";
		Connection con;
		ResultSet rs;
		String s;
		String sqlstr = "SELECT f1, f2, f3 FROM table";

		try 
		{
			Class.forName("org.postgresql.Driver");
		} 
		catch(java.lang.ClassNotFoundException e) 
		{
			System.err.print("ClassNotFoundException: ");
			System.err.println(e.getMessage());
		}

		try
		{
			con = DriverManager.getConnection(url,"postgres", "");

			st = con.createStatement();
			rs = st.executeQuery(sqlstr);

			System.out.println("Rows are :");
			while(rs.next())
			{
				s = rs.getString(1);
  				System.out.println(s);
			}
			System.out.println(mn.gname());
     			rs.close();
			st.close();
			con.close();

		} 
		catch(SQLException ex) 
		{
			System.err.println("SQLException: " + ex.getMessage());
		}

	}

}




Re: sample JSP code connecting to PostgreSQL

От:
Vernon Wu <vernonw@gatewaytech.com>
Дата:

If you are comfortable with tags, you shall consider using JSTL sql tags to do the job for you instead of using scriptlet.


24/02/2003 6:41:07 AM, Tony Grant  wrote:

>On Mon, 2003-02-24 at 02:50, Roj Niyogi wrote:
>
>> I'm wondering if anybody would be pleasant enough to give me a complete 
>> script containing JSP code that makes a simple connection to a 
>> PostgreSQL database, retrieves data and dumps to screen.
>> 
>> I must be dumb not to be able to find this information anywhere on the 
>> net. :(
>
>I just use Dreamweaver MX. 
>
>Or you can build your JSP in NetBeans / SunOne Studio which are free
>tools.
>
>Cheers
>
>Tony Grant
>
>-- 
>www.tgds.net Library management software toolkit, 
>redhat linux on Sony Vaio C1XD, 
>Dreamweaver MX with Tomcat and PostgreSQL
>
>
>---------------------------(end of broadcast)---------------------------
>TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org
>



FAQ