LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 10-16-2011, 03:20 PM   #1
obedraju
LQ Newbie
 
Registered: Oct 2011
Location: Hyderabad
Posts: 18

Rep: Reputation: Disabled
problem in database connection


Hi...
I have run the following code. Everything works on eclipse n netbeans. It shows output on page. But the problem is, i am unable to find any table created on oracle.

Code
-----------------------------------------------------------------
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

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

<%
try
{
Class.forName("oracle.jdbc.driver.OracleDriver");
Connection con = DriverManager.getConnection("jdbcracle:thin:@loc alhost:1521:XE","system","obedraju");
PreparedStatement ps = con.prepareStatement("create table obedraju(obed varchar2(399))");
System.out.println("Loading driver");
}
catch(Exception s)
{}

%>

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body>
Done...
</body>
</html>
-----------------------------------------------------------------

I have downloaded ojdbc14.jar and added to the project.

Can any one help me in getting table created on oracle database.


Thnx...
 
Old 10-16-2011, 04:13 PM   #2
Proud
Senior Member
 
Registered: Dec 2002
Location: England
Distribution: Used to use Mandrake/Mandriva
Posts: 2,794

Rep: Reputation: 116Reputation: 116
Please put your code in [code] tags to preserve indentation and avoid other forum parsing.
Did you mean localhost to have a space in it?

Your printing of the HTML with "Done..." seems unconditional, it is no indication that the Java was executed or successful. I strongly suggest you don't do utterly nothing when any exception is thrown.
 
0 members found this post helpful.
Old 10-17-2011, 12:32 AM   #3
obedraju
LQ Newbie
 
Registered: Oct 2011
Location: Hyderabad
Posts: 18

Original Poster
Rep: Reputation: Disabled
What localhost space?? I mean.. the code is executing perfectly. When it is executed, there should be a table created on database. So my question is, y it is not creating a table on oracle database.
 
Old 10-17-2011, 05:03 AM   #4
Proud
Senior Member
 
Registered: Dec 2002
Location: England
Distribution: Used to use Mandrake/Mandriva
Posts: 2,794

Rep: Reputation: 116Reputation: 116
The space in
Code:
getConnection("jdbc:oracle:thin:@loc alhost:1521:XE","system","obedraju");
Clearly your code isn't executing perfectly if it's not doing what you expect it to. Again, please edit your original post to put your code in the correct forum tags, and then try not silently consuming any Exception that may occur in the try block you've written.
This
Code:
catch(Exception s)
{}
is very very bad.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
script connection to mssql database problem I_AM Linux - Software 0 03-20-2009 05:10 PM
Database connection using C/C++ shydra Programming 7 02-16-2006 12:51 AM
Problem with Postgres Database Connection anjani.78 Linux - Software 1 10-07-2005 02:06 AM
Snort database: Closing connection to database "" Homer Glemkin Linux - Security 2 07-14-2005 06:58 PM
Database connection Cyth Programming 2 12-23-2001 05:04 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 03:27 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration