dcsimg
learning & clarifying doubts
5 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   hanu_shr
Posted On:   Saturday, September 23, 2006 11:08 AM

how do i initialize database in jsp with example

Re: learning & clarifying doubts

Posted By:   Christopher_Koenigsberg  
Posted On:   Monday, October 9, 2006 03:41 PM

You want to create a new database (or just insert new initial data into it?), from an example (like the Oracle one with "Scott" and "Tiger"), and do it all from within a jsp? I suppose you could try using Runtime exec's on the command-line database programs if you can work out the database creation syntax and save it in a script.

Re: learning & clarifying doubts

Posted By:   Anonymous  
Posted On:   Monday, September 25, 2006 03:43 AM

//the very first step is to import java.sql.* package


<%@ page language="java" import="java.sql.*"%>;






String url ="jdbc:odbc:Name";//Name is the name of the datasource

Connection con;

ResultSet rs=null;

Statement stmt;




// this loads the driver


Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");


//this makes the connection


con = DriverManager.getConnection(url, "", "");


stmt = con.createStatement();


stmt.executeUpdate("CREATE TABLE COFFEES " +
"(COF_NAME VARCHAR(32), SUP_ID INTEGER, PRICE FLOAT, " +
"SALES INTEGER, TOTAL INTEGER)");

stmt.close();


con.close();

Re: learning & clarifying doubts

Posted By:   Anonymous  
Posted On:   Saturday, September 23, 2006 06:15 PM

<%@ page import="java.sql.*" %>
<%
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver);
Connection con=DriverManager.getConnection("jdbc:odbc:","username","password");
Statement st=con.createStatement();
ResultSet rs=st.executeQuery("qry");
%>



From
Er.Jyoti Bikash Panda
(Software Engg SR Infotech,Gurgaon)
E-mail:jyotibikash_panda@rediffmail.com
:jyotibikash_panda@yahoomail.com
:jyoti_bikash@sixthquadrant.com

Re: learning & clarifying doubts

Posted By:   WarnerJan_Veldhuis  
Posted On:   Saturday, September 23, 2006 06:05 PM

Besides... If your question is shorter than 10 words, you might want to be more specific. "Need *this* with example" is usually what you feed to google, not a professional programmer...

Re: learning & clarifying doubts

Posted By:   WarnerJan_Veldhuis  
Posted On:   Saturday, September 23, 2006 06:04 PM

You don't initialize a database. The database is *already* running. Then your application is started. It will *use* the database. If you're smart, your JSP doesn't do anything with the database. That's done by the EJB's or the DAO layer (preferably both), but not by the JSP itself. Sounds like a new Google search.....
About | Sitemap | Contact