473,406 Members | 2,956 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

how to connect java programme to a database

12
My java programme is unable to connect to the database..

my code is this

Expand|Select|Wrap|Line Numbers
  1.  
  2.               import java.sql.*;
  3.  
  4.             public   class Stmt
  5.                 {
  6.             public static void main(String args[])throws Exception
  7.                 {
  8.  
  9.                                try{
  10.                        Class.forName("oracle.jdbc.driver.OracleDriver");            
  11.  Connection con=DriverManager.getConnection("jdbc:oracle:thin@localhost:1521:xe","scott","tiger");
  12.                         Statement stmt=con.createStatement();
  13.                         String vsql="create table testtable(cone number,ctwo number)";
  14.                         stmt.executeUpdate(vsql);
  15.                         System.out.println("...Success....");
  16.                         con.close();
  17.                             }
  18.                         catch(ClassNotFoundException e)
  19.                             {
  20.                         System.out.println(e);
  21.                         System.out.println("hello");
  22.                             }
  23.  
  24.           }
  25.   }
  26.  
My java programme is compiling but not running I am getting error as Exception in thread "main" java.sql.SQL exception,connection refused.


Please give answer to my question ,i am struck here and unable to go further
Oct 19 '07 #1
3 1719
JosAH
11,448 Expert 8TB
My java programme is compiling but not running I am getting error as Exception in thread "main" java.sql.SQL exception,connection refused.


Please give answer to my question ,i am struck here and unable to go further
There are a few possible causes:

1) wrong port number
2) wrong user name and/or password
3) no database server running
4) error in your url for the connection request
5) database server too busy already
6) firewall problems

You have to check them all and google a bit.

kind regards,

Jos
Oct 19 '07 #2
rahana
12
There are a few possible causes:

1) wrong port number
2) wrong user name and/or password
3) no database server running
4) error in your url for the connection request
5) database server too busy already
6) firewall problems

You have to check them all and google a bit.

kind regards,

Jos
how can i know the port number,user name,password and url
Oct 19 '07 #3
JosAH
11,448 Expert 8TB
how can i know the port number,user name,password and url
What about reading your database vendor's manual?

kind regards,

Jos
Oct 19 '07 #4

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

Similar topics

1
by: C.O.Jones | last post by:
Using Oracle 8.1.7 Personal edition on Windows XP. I was experimenting with the DBA tools. I first of all tried to adjust the memory used by my database. Then I attempted to shutdown and...
6
by: Jeff Sandler | last post by:
I have a database I created in mySQL. I've been entering data every day into the database using a Java application that I wrote. The database and the Java program are on the same Win 98 SE...
2
by: Mark Delon | last post by:
Hi, i want to log via python script to https page: 'https://brokerjet.ecetra.com/at/' # But it does not work. I am using following code(see below)
0
by: Parvez | last post by:
HI How to connect MS ACCESS in Netwaork base VB6.0 Programme from server I AM DEVLOPING A EMPLOYE ATTANEDENS RECORD PROJECT IN THIS I AM USING VB6.0 AND MS ACCESS AND WINDOEW XP IN MY PROJECT...
11
by: Mikael Arhelger | last post by:
Hello, This has been posted a few times but still I could not find a way to connect to our database. We run DB2 Express on WIN2K server with XP clients. I can ping inside network and to the...
3
by: arasub | last post by:
ep 20, 2007 11:25:57 AM org.apache.catalina.core.AprLifecycleListener lifecycleEvent INFO: The Apache Tomcat Native library which allows optimal performance in production environments was not found...
0
by: thinboy | last post by:
Im having trouble with a Java Home work. I have found the following classes are their anymore This system is intended to provide the school timetabler with information to support his/her...
10
rhitam30111985
by: rhitam30111985 | last post by:
hi all .. java/jdbc newbie here ... i cant seem to perform the most basic step for database connectivity using java . here is my code : import java.sql.*; public class connect { ...
10
nathj
by: nathj | last post by:
Hi there, This thread is very similar to an earlier thread but I didn't want to hijack a thread. The issue is this. I have a mysql database on my local machine, I have installed the driver for...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
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...

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.