Article View: be.comp.programming
Article #10880Re: jsp-databank
From: Gaizka
Date: Thu, 21 Feb 2002 21:56
Date: Thu, 21 Feb 2002 21:56
81 lines
3250 bytes
3250 bytes
(Pino) wrote:
>>Gaizka wrote
>> Welke DB dacht je te gebruiken ?
>>
>MsAcces, ik weet dat het niet goed is om veel gebruikers toe te laten, maar
>ik kan er al wat mee werken.
Stap1
Set up a DSN for your Access database.
� Open the Windows ODBC Data Source Administrator as follows:
� In Windows 95, 98, or NT, choose Start > Settings > Control Panel,
then double click on the ODBC Data Sources icon
� In Windows 2000, choose Start > Settings > Control Panel >
Administrative Tools > Data Sources
� In the ODBC Data Source Administrator dialog box, click the System
DSN tab, then click Add to add a new DSN to the list.
� Select "Microsoft Access Driver (*.mdb) from the list, then click
Finish
� Specify a name for the DSN, like myAccessDatabase
� Click Select to locate your Access database file on your hard drive
� Click OK to close the dialog box
Stap 2
test.html
<html>
<head>
</head>
<body>
<form action="insert.jsp">
Field1:
<input type="text" name="fieldname1" size="20">
<br>
Field2:
<input type="text" name="fieldname2" size="20">
<input type="submit" value="ok">
</form>
</body>
</html>
insert.jsp
//verwerk dbname door de naam van jouw DB
<%@ page import="java.sql.*" %>
<%
Connection connection;
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
connection =DriverManager.getConnection("jdbc:odbc:dbname");
Statement statement=connection.createStatement();
String var1= request.getParameter("fieldname1");
String var1= request.getParameter("fieldname2");
String sql = "insert into dbname values ('"+fieldname1+"',
'"+fieldname2+"')";
statement.executeUpdate(sql);
statement.close();
connection.close();
}
catch(ClassNotFoundException cnfex)
{
out.println("jdbc odbc driver not found");
}
catch(SQLException sqlex)
{
out.println(sqlex);
}
%>
Operation successfull
Misschien
http://www.devshed.com/Server_Side/Java/JSP/JSP5/page1.html
ook is bekijken
Technical Details
Message-ID:
<3qna7u875124hvjos0fdhape31rvse90v4@4ax.com>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-03!supernews.com!news3.cnt.ru!srcc!newsfeed.gamma.ru!Gamma.RU!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsfeed.easynews.net!easynews.net!feed1.news.be.easynet.net!news.be.easynet.net!not-for-mailReferences:
<Xns91BCC0AEBB1E5pinocooremanhotmailc@195.130.132.65> <7gha7ugptnmhcibfnpeh02fevpsrrm7qg3@4ax.com> <Xns91BCCEF2621A0pinocooremanhotmailc@195.130.132.65>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII X-Google-Thread: fcea4,cc60406e68789b26 X-Google-Attributes: gidfcea4,public X-Google-ArrivalTime: 2002-02-21 13:58:10 PST Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-03!supernews.com!news3.cnt.ru!srcc!newsfeed.gamma.ru!Gamma.RU!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsfeed.easynews.net!easynews.net!feed1.news.be.easynet.net!news.be.easynet.net!not-for-mail From: Gaizka <gaizka@nospam.easynet.be> Newsgroups: be.comp.programming Subject: Re: jsp-databank Date: Thu, 21 Feb 2002 22:56:24 +0100 Organization: [ posted via Easynet Belgium ] Lines: 81 Message-ID: <3qna7u875124hvjos0fdhape31rvse90v4@4ax.com> References: <Xns91BCC0AEBB1E5pinocooremanhotmailc@195.130.132.65> <7gha7ugptnmhcibfnpeh02fevpsrrm7qg3@4ax.com> <Xns91BCCEF2621A0pinocooremanhotmailc@195.130.132.65> NNTP-Posting-Host: 212-100-181-86.adsl.easynet.be Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Trace: rivage.news.be.easynet.net 1014328619 3597 212.100.181.86 (21 Feb 2002 21:56:59 GMT) X-Complaints-To: abuse@easynet.be NNTP-Posting-Date: 21 Feb 2002 21:56:59 GMT X-Newsreader: Forte Agent 1.8/32.553