• Post Reply Bookmark Topic Watch Topic
  • New Topic

oracle connectivity  RSS feed

 
gurcharan singh
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
HY!
I am new to oracel i had run the JdbcCheckup programme provided with oracle but when ever i run i get neither output nor any error.
I had created a table BOOKING and I am quering the same table form the programme-:
the code import java.io.*;
import java.sql.*;
class JdbcCheckup
{
public static void main(String args[])
throws SQLException,IOException
{
DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
System.out.println("pls enter inf. to enter test connection");

String user;
String password;
String database;

user = readEntry("user: ");
int slash_index = user.indexOf('/');
if(slash_index != -1)
{
password = user.substring(slash_index +1);
user = user.substring(0, slash_index);
}
else
password = readEntry("pasword");
database = readEntry("database (a TNSNAME entry): ");
System.out.print("Connecting to database");
System.out.flush();

System.out.println("Connecting...");
Connection conn = DriverManager.getConnection("jdbc racle ci8:@" + database,user,password);
System.out.println("connected");
Statement stmt = conn.createStatement();
ResultSet rset = stmt.executeQuery("select consignor from BOOKING;");
System.out.println(rset.getString(1));
//System.out.println("your JDBC connection is OK!");

rset.close();
stmt.close();
conn.close();
}

static String readEntry(String prompt)
{
try
{
StringBuffer buffer = new StringBuffer();
System.out.print(prompt);
System.out.flush();
int c = System.in.read();
while(c != '\n' && c!= -1)
{
buffer.append((char)c);
c=System.in.read();
}
return buffer.toString().trim();
}
catch (IOException e)
{
return "";
}

}
}
 
Mark Spritzler
ranger
Sheriff
Posts: 17309
11
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can you throw exceptions in Public Static Void main()?
Are you getting any of the System.outs to print?
Mark
 
gurcharan singh
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanxs for response No I am not getting any of the print statement.Whenever i write command -: "java jdbcCheckup" I just get out of the command without any response.
 
Mark Spritzler
ranger
Sheriff
Posts: 17309
11
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try removing the throws statement from the main method, and put all the code in that method surrounded by a try-catch. and just catch (Exception e) for right now, and put a System.out.println("I am in the Catch.") to see what happens.
Mark
 
gurcharan singh
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,
yes i had done as u told me and also this time i didn't given any database name.
now i am getting trap in the try catch block and also getting error msg-:EOJ_DATABASE_IS_NULL.
Regards,
gurcharan
 
Mark Spritzler
ranger
Sheriff
Posts: 17309
11
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And you still say you are getting no output in your console window?
Mark
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!