473,943 Members | 11,648 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Help with connecting JSP to Oracle

9 New Member
Hi, I have been trying to connect my JSP file to my Oracle database but the server does not seem to like it and won't connect, I have the following code:

<%@ page language="java" contentType="te xt/html" errorPage="erro rpage.jsp" import="java.sq l.*" %>

<html><head><ti tle>Login</title></head>
<body>
<% //1. load the SQL JDBC driver
Class.forName(" oracle.jdbc.dri ver.OracleDrive r");

// 2. Open a connection to the database
Connection Conn = DriverManager.g etConnection("j dbc:oracle:thin :");

// 3. create a statement object for sending sql queries
Statement Stmt = Conn.createStat ement();

// 4. place the query results in a ResultSet object
ResultSet RS = Stmt.executeQue ry
("SELECT message
FROM manstaffdb
WHERE name = '" + request.getPara meter("name") + "'
AND password= PASSWORD('" + request.getPara meter("password ")+"')");

// 5. assign ResultSet's column 1 to a String variable
String message = null;
while(RS.next() ) { message = RS.getString(1) ; }

// 6. Clean up all objects
RS.close(); Stmt.close(); Conn.close();
%>

<% if(message != null){
session.setAttr ibute("welcome" , message); %>

<h4>Your login has succeeded. Thank you.</h4>
<% } else { %>
<h4>Your login has failed, please try again.</h4>
<% } %>

<a href="<%= response.encode URL("db-login.jsp") %>">
Continue...</a>
</body></html>

Can anyone see where I'm going wrong??

Thank you!
Jan 18 '07 #1
1 2603
sadashiv
1 New Member
Hi, I have been trying to connect my JSP file to my Oracle database but the server does not seem to like it and won't connect, I have the following code:

<%@ page language="java" contentType="te xt/html" errorPage="erro rpage.jsp" import="java.sq l.*" %>

<html><head><ti tle>Login</title></head>
<body>
<% //1. load the SQL JDBC driver
Class.forName(" oracle.jdbc.dri ver.OracleDrive r");

// 2. Open a connection to the database
Connection Conn = DriverManager.g etConnection("j dbc:oracle:thin :");

// 3. create a statement object for sending sql queries
Statement Stmt = Conn.createStat ement();

// 4. place the query results in a ResultSet object
ResultSet RS = Stmt.executeQue ry
("SELECT message
FROM manstaffdb
WHERE name = '" + request.getPara meter("name") + "'
AND password= PASSWORD('" + request.getPara meter("password ")+"')");

// 5. assign ResultSet's column 1 to a String variable
String message = null;
while(RS.next() ) { message = RS.getString(1) ; }

// 6. Clean up all objects
RS.close(); Stmt.close(); Conn.close();
%>

<% if(message != null){
session.setAttr ibute("welcome" , message); %>

<h4>Your login has succeeded. Thank you.</h4>
<% } else { %>
<h4>Your login has failed, please try again.</h4>
<% } %>

<a href="<%= response.encode URL("db-login.jsp") %>">
Continue...</a>
</body></html>

Can anyone see where I'm going wrong??

Thank you!
Hi,
you should specify host ip, database name, username and password in Connection Conn line as given below
Connection Conn = DriverManager.g etConnection("j dbc:oracle:thin :@hostname:port :dbname","usern ame","password" );
This may help you
Jan 24 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

4
9351
by: Mark Wilson CPU | last post by:
A colleague has written a prototype program in PHP, using a MySQL database. It's a relatively simple app, with a restricted set of mysql commands used (see below). The MySQL DB is being replaced with an Oracle DB (same schema). My plan 1) globally replace the few mysql commands with intermediate equivalents (such as myDB_connect for mysql_connect) 2) those central functions would then (for now) call the original mysql function to prove...
2
1575
by: Tony Teoh | last post by:
All, Current Im develop a program that using web page to connect to Oracle. My difficulties was: 1) How to retrieve the information in tnsnames.ora and put into all connection string into a option list to let user choose accordingly ? 2) After using had choosen the connection then a username and passowrd page will appear to let user key in the username and password, if verify is ok then proceed to do other stuffs else put back to...
1
5282
by: Munk | last post by:
Hi, I'm learning sql and my instructor used sql*plus in oracle to explain some basic sql statements. I downloaded the latest oracle and installed it. I'm having some problems getting sql plus to work. It seems to have problems connecting and I have no idea how to connect, I haven't got a preconfigured database or anything. Can anybody tell me how to get it working?
1
3196
by: Wayne Happ | last post by:
I have Oracle 9 running on a Linux RedHat Box V9.0. But I'm having trouble connecting from a windows machine via PL/SQL Develover. When I startup the application the instance name appears but when I try to login as sysdba I get the error. ORA-12545 Connection failed because target host or object does not exist. I'm guessing that there's something net8 I have to setup. This is a new installation. Can someone point me in the right...
0
1386
by: Kong Li | last post by:
Follow up to this thread, the latest Oracle 9i release 2 patchset (9.2.0.5) fixed the handle count leak problem. The problem is in Oracle client component. Thanks. Kong ----- From: Kong Li (likong@email.com)
1
2172
by: Jyrki H | last post by:
We have done a complex software with VB using SQL Server through ADO. Now our customer is planning to switch from SQL Server to Unix/Aix Oracle 8 DB. I'm a newbie both in Oracle and Unix and wonder how this will affect our software. Would changing the connection string be enough (I quess not). Any help would be appreciated ! Jyrki Hamalainen Laukaa, Finland
1
1764
by: yahibble | last post by:
Now, I am no Python expert but I have dabbled and I have spent a couple of days with another engineer unsuccessfully installing oracle drivers for MS ODBC on the win XP machine. It looked to me like ODBC was the best way to get a (free) python module to upload data to an oracle database table. Aside from installing oracle clients to ODBC being a pain, I would like to consider other ways to connect. Has anyone had experiences with...
2
3469
by: python_eager | last post by:
Hi i am connecting my database oracle 9i. While connecting i am getting the following error connection = cx_Oracle.connect("myusername", "mypassword", "python") RuntimeError: Unable to acquire Oracle environment handle please send the solution
0
1648
by: antonyliu2002 | last post by:
I am having a hard time connecting to an oracle database from within Visual Web Developer (VWD) 2005 Express Edition. Check out the screen snap shot here: http://static.flickr.com/97/241874792_aebbadac2b_o.gif Here is the situation: 1. The oracle database runs on Machine A.
0
3158
by: Temporary | last post by:
C# Web Service in IIS Stops Connecting to Oracle (via ADO.NET) Over Time I have a Web Service, written in C#, published on a Windows XT Web Server under IIS, which repeatedly connects to an Oracle 9x database via ADO, processes, disconnects from the database, and exits. The Web Service is triggered by our Tibco messaging system; in our test environment, it is
0
10138
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9970
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
11538
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10666
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
8226
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
7392
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
4913
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
4515
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3516
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.