473,441 Members | 2,458 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,441 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 1720
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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,...
1
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
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...
0
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...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.