Connecting to an oracle database
Hi! I am a student of Computer Engineering. I was hoping someone could help me out giving me options of could be wrong in my database application.
The problem is this:
I connect to an oracle database and i have a username, password and an url direction. Apparently the connection is fine, because my program does not show any errors or exceptions, but when I try to retrieve data from the tables I have in my space of the database, the ResultSet object appears to be empty. And I don't have any idea what the problem is, because when I write the select statement directly in the console, the database retrieves me the information I ask, but it doesn't retrieve me anything when I do it through my program.
I will put the part of my code that is causing me trouble... I hope someone can help me:
//this is the part when I connect to the database
public void connectToDB() {
try {
// Register the ORACLE: oracle:thin driver
try {
DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
catch (NoClassDefFoundError e){
System.out.println(e);
return;
System.out.println("Oracle driver succesfully loaded.");
// Connection
System.out.println("Connecting to the database... ");
conn = DriverManager.getConnection(CONEXION_URL,USUARIO,
PASSWORD);
System.out.println("Authentification process...");
System.out.println("Access granted.");
System.out.println("Connection successful.");
//conn.setAutoCommit(true);
} catch (SQLException e) {
System.out.println("Connection failed!");
System.out.println(e);
//this is the part when I make a select statement that doesn't retrieves me
//anything
public void consultaRecibosPeriodo(){
String nombre="",domicilio,fechaContrato,fechaExpedicion;
int importe;
String query = "SELECT NOMBRE FROM CLIENTE";
try{
if(conn!=null){
System.out.println("Entra a consultaRecibosPeriodo");
Statement stmt = conn.createStatement();
ResultSet resultado = stmt.executeQuery(query);
System.out.println(conn);
while(resultado.next()){
System.out.println("entra al while ");
nombre=resultado.getString("NOMBRE");
System.out.println("nombre " + nombre);
}catch(SQLException e){System.out.println("Error: " + e);}
}
Hi,
Before loop on your resulset check add this test :
if(resultado.first()) {
while(resultado.next()){
System.out.println("entra al while ");
nombre=resultado.getString("NOMBRE"); // Is NOMBRE is a filed in your table ??
System.out.println("nombre " + nombre);
}skippye
Similar Messages
-
Connecting to an Oracle database after clicking on a foi
Does anyone know how or have any examples on how to connect to an oracle database after clicking on a 'feature of interest' in MapViewer? I want to be able to click on a 'feature of interest' on the map, and have a list of records from an oracle table displayed using the identified key of the foi. I am able to create the feature of interest, and add the event listener for 'mouse click', but am unsure how to connect to the database at this point. I have been able to connect to the database in a different jsp, but not from here. Thank you.
1. Create a JSP page that does the database query. It should take the foi id as an input parameter.
2. In the foi mouse click listener, display the JSP page in iframe. The iframe can be placed outside the map or inside the info window. The function should do something like this.
function myClickListener(point, foi)
mapview.displayInfoWindow(point, "<iframe id='my_iframe_id' frameborder=0 width=300px height=400px />", 300, 400) ;
var myIframe = document.getElementById("my_iframe_id") ;
myIframe.src = "http://myhost/myjsp?key=" + foi.id ;
} -
Problem connect form6i and Oracle Database 10g
I can't connect form6i to Oracle Database 10g
When complete user/password@database fatal error produce:
"Oracle Forms Designer has encountered a problem and needs to close. We are sorry for the inconvenience"
Error Detail:
AppName: ifbld60.exe AppVer: 6.0.8.27 ModName: ora805.dll
ModVer: 0.0.0.0 Offset: 000b4f04
Product Install:
- Forms Version: Forms [32 bits] Versión 6.0.8.27.0
- Oracle Database: 10.2.0
- Win XP professional with SP2.
Any idea what might cause Forms to shutdown ubnormally?
ThanksIf your database is using the AL32UTF8 character set, Forms 6i cannot connect.
Read this thread:
connecting form 6i to oracle database 10G express edition -
Trouble connecting to remote oracle database
Hi,
i'm having trouble connecting to an oracle database (Release 9.2.0.6.0) using the ojdbc14.jar from the oracle website. Can anybody spot the problems that i need to sort out to get it working? Code and error stack below.
Thanks,
Pat
Code:
import java.sql.*;
public class Query1 {
public static void main (String[] args) {
try {
Class.forName("oracle.jdbc.driver.OracleDriver");
String url = "jdbc:oracle:thin:@175.3.41.248/KNWAPROD";
String user = "username";
String password = "password";
Connection conn = DriverManager.getConnection(url,user,password);
Statement stmt = conn.createStatement();
ResultSet rs;
rs = stmt.executeQuery("select count(*) from FACT_FAULT;");
while ( rs.next() ) {
// String lastName = rs.getString("Lname");
System.out.println("In while loop!");
conn.close();
} catch (Exception e) {
e.printStackTrace();
System.err.println("Got an exception! ");
System.err.println(e.getMessage());
Error stack:
java.sql.SQLException: Io exception: SO Exception was generated
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:125)
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:162)
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:274)
at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:319)
at oracle.jdbc.driver.PhysicalConnection.<init>(PhysicalConnection.java:344)
at oracle.jdbc.driver.T4CConnection.<init>(T4CConnection.java:148)
at oracle.jdbc.driver.T4CDriverExtension.getConnection(T4CDriverExtension.java:32)
at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:545)
at java.sql.DriverManager.getConnection(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)
at Query1.main(Query1.java:13)
Got an exception!
Io exception: SO Exception was generatedYou have:
String url = "jdbc:oracle:thin:@175.3.41.248/KNWAPROD";Example URLs I've seen/used are:
String url = "jdbc:oracle:thin:@//myhost:1521/orcl";
String URL = "jdbc:oracle:thin:scott/tiger@//myhost:1521/orcl"In other words, I think you've munged your URL; you need some slashes and a port number (1521 is the default). -
Connecting to an Oracle database using ASP
Hi
I am having problems connecting to an Oracle database using ASP. I am trying to do this for a school project the school's database server is running Oracle 9i. The repository is version 6. The web server I have access to only has ASP not ASP.net. What kind of connection string would I need to be able to connect to the database?You do need to ensure that the Oracle client and Oracle server are compatible, but that is generally pretty easy to accomplish. Unless you are trying to cross more than one major release (i.e. 9.2 client to a 7.3.4 database), you're pretty safe there.
You could try downloading and installing the latest 8.1.7.x Oracle ODBC driver from OTN on the machine with the 8.1.7 Oracle client (I believe the last ODBC patchset was 8.1.7.10), but I don't have particular confidence that that will solve the problem. If it doesn't, we can do an ODBC trace to focus in on the issue, but installing a new driver is a much easier process, so that probably ought to be the first step.
Justin
Distributed Database Consulting, Inc.
http://www.ddbcinc.com/askDDBC -
Error when connecting to an Oracle Database
Hi, I'm trying to connect to an oracle database by calling a javabean from a jsp page. When I try to connect however I get this error:
java.lang.UnsatisfiedLinkError: C:\oracle\ora92\jdbc\lib\ocijdbc10.dll: The specified procedure could not be found
java.lang.ClassLoader$NativeLibrary.load(Native Method)
java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1751)
java.lang.ClassLoader.loadLibrary(ClassLoader.java:1676)
java.lang.Runtime.loadLibrary0(Runtime.java:822)
java.lang.System.loadLibrary(System.java:992)
oracle.jdbc.driver.T2CConnection.loadNativeLibrary(T2CConnection.java:2963)
oracle.jdbc.driver.T2CConnection.logon(T2CConnection.java:225)
oracle.jdbc.driver.PhysicalConnection.<init>(PhysicalConnection.java:348)
oracle.jdbc.driver.T2CConnection.<init>(T2CConnection.java:139)
oracle.jdbc.driver.T2CDriverExtension.getConnection(T2CDriverExtension.java:79)
oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:563)
java.sql.DriverManager.getConnection(DriverManager.java:525)
java.sql.DriverManager.getConnection(DriverManager.java:171)
I am trying to connect to the database using OCI and its tns name. Also right now I'm just using the tomcat bundled in the netbeans ide.
Anyone have any ideas on what's wrong?Why not use a type IV JDBC driver, available forfree download from Oracle? No
need for any DLL then.The standard Oracle driver comes with "oci" and
"thin" drivers.
Thin driver is 100% java.
oci driver uses the dlls.
What version of Oracle are you using? I am guessing
10?
Have you got Oracle Client installed on this machine?
(Stupid question I know)
What URL connection string are you using?
Does the "thin" driver work? ie url
"jdbc:oracle:thin:@[IP_ADDRESS]:[PORT]:[SID]"
Cheers,
evnafetsThere's another advantage of the thin driver: you don't have to have the client installed or TNS names defined for it to work.
% -
Connecting to Non-Oracle Databases
How can we connect to Non-oracle databases like MS-SQL server using Developer Forms and reports?
can any body please provide steps to do this.HI
to connect to Non-Oracle Database u have to use OCA ,,,u have to define ODBC data source for the database <source1> u want to connect. to connect from the forms or reports
user name/password@ODBC:source1.
hope this help u
try to look for the developer help -
Connecting to an oracle database questions
<p>Our current solution to connecting to our oracle database uses the following code:</p><p> ReportClientDocument clientDoc = new ReportClientDocument;</p><p> java.sql.ResultSet rs = fetchResultSet(driverName, connectStr, userName, password, <u>query</u>);</p><p> clientDoc.getDatabaseController().setDataSource(rs, <u>tableName</u>,tableName+"_ResultSet"); </p><p>The code for subreports is very similar, but isn't necessary for my question. The problem w/ this approach is we have to define the SQL query and the table name in the JSP, which we shouldn't have to do considering both of these are stored in the report. Any changes to the reports' sql would then require someone to edit the jsp, which is just bad. </p><p>I have been reading up on the ConnectionInfo and ConnectionInfos classes (nice naming convention btw) and the CrystalReportViewer.setDataBaseLogonInfos() method, and I believe a solution may lie here. The problem is the tutorials on using the ConnectionInfo class assume the database name is stored in the report, and we do not want to assume this. We are developing our reports to be used by our customers, who may name their database whatever they want so long as the tables inside it are what we specify. Because of this assumption, I have yet to find a good explanation of how to use the setAttributes(PropertyBag) method which is the only I have seen to specify the database name (within a connection string). I have examples of it, but nothing that defines the key/value pairs required in the PropertyBag to create a connection to an oracle database. </p><p>Is there some documentation on the key/value pairs needed by the PropertyBag? Also, if there is another (easier) solution I am overlooking then please let me know, thanks.</p><p>-Sam Morehouse</p><p>HBF Group, Inc </p><p> </p>
<p>got it working, here's some sample code. </p><p> </p><p><%<br /> try{<br /> ReportClientDocument clientDoc = new ReportClientDocument();<br /> clientDoc.open(reportName, 0);<br /> <br /> ConnectionInfos connInfos = new ConnectionInfos();<br /> IConnectionInfo iConnInfo = new ConnectionInfo();<br /><br /> PropertyBag bag = new PropertyBag();<br /> bag.put("Database Class Name",driverName); // "oracle.jdbc.driver.OracleDriver"<br /> bag.put("Connection URL",connectStr); // "jdbc:oracle:thin:@dbName:1521:sid"<br /> <br /> PropertyBag pb = new PropertyBag();<br /> pb.put(PropertyBagHelper.CONNINFO_CRQE_LOGONPROPERTIES ,bag);<br /> pb.put(PropertyBagHelper.CONNINFO_DATABASE_DLL ,"crdb_jdbc.dll");<br /> iConnInfo.setAttributes(bag);<br /> <br /> iConnInfo.setUserName(userName);<br /> iConnInfo.setPassword(password); <br /> <br /> iConnInfo.setAttributes(pb);<br /> <br /> connInfos.add(iConnInfo);<br /> session.setAttribute(reportName, clientDoc);<br /> session.setAttribute("reportSource", clientDoc.getReportSource());<br /><br /> //Setup viewer. Only going to include the relevant line, the rest can be found</p><p> //elsewhere.<br /></p><p> CrystalReportViewer oCrystalReportViewer = new CrystalReportViewer(); oCrystalReportViewer.setDatabaseLogonInfos(connInfos); } </p><p>catch(ReportSDKExceptionBase exc)%></p>
-
Connect to Remote Oracle Database
I am unsuccessfully trying to connect to remote Oracle database using OleDB/ODBC/Oracle Client.
Do I have to install Oracle Client in order to use those drivers and which version?
I would really appreciate any help. THANK YOU!Marina,
Please refer this question to the general Installation forum. Thanks!
The short answer is yes, you need to have the Oracle client software installed. -
Connect to an Oracle database by using oracle.jdbc.OracleDriver: error
Hi,
I'm trying to connect to an Oracle database so we can retrieve notes of tables, views and packages.
By using the API of Data Modeler (transformation script) we want to add these notes to corresponding objects in Data Modeler.
I'm starting with this:
importPackage(java.lang);
importPackage(java.awt);
importPackage(java.sql);
java.lang.Class.forName("oracle.jdbc.OracleDriver");
An error occurs when I run this code:
It has to be a Java thing...
Anyone a suggestion?Problem solved! One of my colleagues referred to this post: Import user defined properties from Oracle Designer
More in detail: it's about this couple of lines:
// Copy the ojdbc6.jar file to ..\datamodeler-home\jlib directory
// Add this line to datamodeler.conf
// AddJavaLibFile ../../jlib/ojdbc6.jar
I changed my datamodeler.conf file, restarted DM and now there's no longer an error when I am trying to use the Oracle JDBC drive. -
Urgent : Hoe to connect to a ORACLE database throught WEBDYNPRO JAVA
HI All
i am very new to Developer Studio,
i want to connect to an oracle database through wedynpro java.
i have seen some tutorials on SDN. i know something about adding external JARs and OJDBC .
Can anyone send me the sample code to connect to a database
<b>very urgent</b>
Thanks in advance
SushmaHi Sushma
Ask your system Admin for servername,portnumber of database server
Connection conn=null;
try {
Class.forName("oracle.jdbc.driver.OracleDriver");
DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
conn =DriverManager.getConnection ("jdbc:oracle:thin:@<servername>:<portnumber>:DB","uname", "pwd");
Statement stmt=conn.createStatement();
ResultSet rs=stmt.executeQuery("select * from <tablename>"); // select statment
while(rs.next())
IXXElement nodeConnection=wdContext.createXXElement(); //creating a node to store the data from oracle
nodeConnection.setYY(rs.getInt("YY")); // setting the values into input fields
nodeConnection.setAA(rs.getInt("AA"));
nodeConnection.setBB(rs.getInt("BB"));
wdContext.nodeXX().addElement(nodeConnection); // adding the node
catch(Exception ex)
finally
try
conn.close(); // closing the connection
catch(Exception e)
welcome to SDN and All the best from SDN Webdynpro JAVA
Regards
Chaitanya.A -
Software to connect to a Oracle database server.
Does anyone know of software that enables me to connect to a Oracle database server, and check out the content? Doesn't need to have a gui.
Orjanp...JAVA + JDBC type 4.
-
Unable to connect to my Oracle Database with Microsoft's ODBC for Oracle driver
I am unable to connect to my Oracle Database with Microsoft's ODBC for Oracle driver vers.2.573.4202.00 on a Win98 computer.
First, I create a "Net Service Name" in order for the ODBC Driver to find the Oracle server. I then created a System DSN in the ODBC Data Source Administrator and assigned the "Net Server Name" as the server in the "Microsoft ODBC for Oracle Setup". But when I test this DSN with Oracle's provided "Oracle ODBC 32Bit Test vers.2.5.3.1.0" I get an error:
SQLSTATE: NA000
Native Error Code:0
Driver Message:[Microsoft][ODBC driver for Oracle][Oracle]
This error occurred on all three Win98 computers I have tried. It does however, seem to work fine on WinNT 4.0, and believe it or not, on the two Win95 computers I have tried.
Does anyone have any fixes, recomendations, or advice?
Thank you,
Eric Edwards
nullWhy are yu not using the Oracle ODBC driver - these can be downloaded from OTN.
Have you set up a tnsnames.ora entry for the Oracle database you want to connect to? Does this name have a domain name added to it? Check %ORACLE_HOME%\network\admin\tnsnames.ora for the service name. If it is a name of the form :
name.domain.subdomain
then you should try using this full name when configuring the ODBC data source.
null -
How to connect Java to oracle Database Express Edition?
Anyone can help me?
How to connect JAVA TO ORACLE DATABASE EXPRESS EDITION?I suggest you to read this article:
http://wiki.oracle.com/page/JDBC
Regards,
Ricky -
No connection to an oracle database
Hello
I have installed database Rel. 2. JDevelopper 9.0.3.2 with BI Beans 9.0.3.6.
Additionally I installed the warehouse builder 9.2.0.2.8.
After I created a repository, a runtime repository and a target schema, I wanted to connect to my Oracle Database. But in the second window when you create a connector I can't choose a database. I can only mark unspecified...
Does anybody know why???
DamianYes I tried to use OWB.
I looked at OTN Documentation
(Oracle9i Warehouse Builder Installation and Configuration Guide)
So I installed OWB Design Time with the Installer, then I
installed the Design Repository using the Repository
Assistant. In addition I performed the OWB Server Side installation using Oracle Universal Installer. Then I installed a Runtime Repository, a Runtime Access User and a Warehouse Builder Target Schema.
After this installation I started the OWB Client and connected as Repository User. I received the make a ODBC Connection. But I want also make a connection to my local oracle database within a connector...
Now in this Printscreen (http://home.datacomm.ch/crettaz/printscreen.jpg) I can't choose my database. I have do configure more things?
Maybe you are looking for
-
The difference between the bubble and the panel
I just experienced another reason why I hate the bubble instead of the drawer/panel, besides the whole data entry thing. I had the calendar on my smaller 20" monitor on my right - I use my 30" monitor for the nuts and bolts of my work. The calendar w
-
G/L account determination through material account assignment group
Hi , I would really appreciate any help on this . The scenario is . We changed the account assignment group of maetrial to 01 just 2 days back. We have old open sales order line up for this particular material . When I am trying to Bill these
-
I am trying to create an icloud account and have used itunes for years . Therefore have been using my apple id to sign in. Unfortunatly it keeps coming back saying this is my apple id but not my icloud id is this different? Ive looked at help and it
-
Both FaceTime and iMessage is not working on my Macbook Air
My facetime and imessage both randomly stopped working last week. I upgraded to Mavericks a few weeks ago but have only been having an issue for around a week. I have found that they do work if I log into my guest account, but they do not work on m
-
I have an interface that got a Java Mapping. This interface is from a non-sap system to SAP (xml to Idoc). I have to change some stupid thing in the mapping, but the problem is that I dont know how can I do this. I go to Mapping Objects\Imported Arch