_Esam
asked on
JDBC example to populate a regular bean from SQL Server 2000
Hi Experts,
I need a simple example to populate a regular bean with JDBC connections for SQL Server 2000.
I need to see what driver to load (I have Windows XP with Tomcat)
How to connect to the SQL Server.
How to populate the bean.
How to use the bean to output the properties of the bean in JSP.
I need a code snippet and a simple explanation.
Thank you.
Regards,
_Esam
I need a simple example to populate a regular bean with JDBC connections for SQL Server 2000.
I need to see what driver to load (I have Windows XP with Tomcat)
How to connect to the SQL Server.
How to populate the bean.
How to use the bean to output the properties of the bean in JSP.
I need a code snippet and a simple explanation.
Thank you.
Regards,
_Esam
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Hi,
Sorry for the late reply....but the accepted answer was exactly what I was looking for...
Excellent...
Thanks...
_Esam
Sorry for the late reply....but the accepted answer was exactly what I was looking for...
Excellent...
Thanks...
_Esam
Cheers _Esam :-)
I am assuming here that you are connecting to your SQL server over a JDBC-ODBC bridge
public class DbBean
{
Connection DataBCon;
Statement stmt;
public Statement connect()
{
try{
DataBDriver = (Driver)Class.forName("sun
DataBCon = DriverManager.getConnectio
stmt = DataBCon.createStatement()
return stmt;
}
catch(Exception e)
{
return null;
}
}
}
Now in your beans you can instanciate this class, get a statment and use it for data fetching