[b]Java JDBC and Oracle DB URGENT HELP PLEASE[/b]

Hello, I am a newbie. I'm very interested in Java in relation to JDBC, Oracle and SAP.I am trying to connect to an Oracle DB and I have problems to display the output on the consule in my application. What am I doing wrong here . Please help me. This is my code: Please Explain
import java.sql.*;
import java.sql.DriverManager;
import java.sql.Connection;
public class SqlConnection {
public static void main(String[] args) {
Class.forName("oracle.jdbc.driver.OracleDriver"); //Loading the Oracle Driver.
Connection con = DriverManager.getConnection
("jdbc:orcle:thin:@34.218.5.3:1521:ruka","data","data"); //making the connection.
Statement stmt = con.createStatement ();// Sending a query to the database
ResultSet rs = stmt.executeQuery("SELECT man,jean,test,kok FROM sa_kostl");
while (rs.next()) {
String man = rs.getString("1");
String jean = rs.getString("2");
String test = rs.getString("3");
String kok = rs.getString("4");
System.out.println( man, jean, test,kok );//here where my the
//compiler gives me errors
stmt.close();
con.close();
}

Hello, I am a newbie. I'm very interested in Java in
relation to JDBC, Oracle and SAP.I am trying to
connect to an Oracle DB and I have problems to
display the output on the consule in my application.
What am I doing wrong here . Please help me. This is
my code: Please Explain
import java.sql.*;
import java.sql.DriverManager; <--- Why do you have these (java.sql.* is enough)
import java.sql.Connection;
public class SqlConnection {
public static void main(String[] args) {// Where's the try/catch block?
>
Class.forName("oracle.jdbc.driver.OracleDriver");
//Loading the Oracle Driver.
Connection con = DriverManager.getConnection
("jdbc:orcle:thin:@34.218.5.3:1521:ruka","data","data"
); //making the connection.
Statement stmt = con.createStatement ();// Sending a
query to the database
ResultSet rs = stmt.executeQuery("SELECT
man,jean,test,kok FROM sa_kostl");
while (rs.next()) {
String man = rs.getString("1");
String jean = rs.getString("2");
String test = rs.getString("3");
String kok = rs.getString("4");
System.out.println( man, jean, test,kok );//here
where my the
//compiler gives me errors
stmt.close();
con.close();
}The compiler is probably complaining about the lack of a try/catch block.
The fact that you can't understand the compiler messages, and didn't read the javadocs enough to know that you needed a try/catch block, suggest to me that you need to learn a lot more about Java. This is pretty fundamental stuff.
When you have problems, it's best to include information about what the compiler or runtime is telling. Error messages and stack traces are helpful.
In your case the error is so elementary that more information isn't necessary.
%

Similar Messages

  • b font color ='red' Java JDBC and Oracle DB URGENT HELP PLEASE /font /b

    Hello, I am a newbie. I'm very interested in Java in relation to JDBC, Oracle and SAP.I am trying to connect to an Oracle DB and I have problems to display the output on the consule in my application. What am I doing wrong here . Please help me. This is my code: Please Explain
    import java.sql.*;
    import java.sql.DriverManager;
    import java.sql.Connection;
    public class SqlConnection {
         public static void main(String[] args) {
              Class.forName("oracle.jdbc.driver.OracleDriver"); //Loading the Oracle Driver.
              Connection con = DriverManager.getConnection
              ("jdbc:orcle:thin:@34.218.5.3:1521:ruka","data","data"); //making the connection.
              Statement stmt = con.createStatement ();// Sending a query to the database
              ResultSet rs = stmt.executeQuery("SELECT man,jean,test,kok FROM sa_kostl");
              while (rs.next()) {
                   String man = rs.getString("1");
                   String jean = rs.getString("2");
                   String test = rs.getString("3");
                   String kok = rs.getString("4");
                   System.out.println( man, jean, test,kok );//here where my the
                                                 //compiler gives me errors
              stmt.close();
              con.close();
    }

    <b><font color ='red'>Java JDBC and Oracle DB URGENT HELP PLEASE</font></b>Too bad your attempt at getting your subject to have greater attention failed :p

  • SQL PRO AND ORACLE SQL URGENT HELP

    Can any one help me out here withe these questions:
    Pro C Qusetions:
    1.     What are the SQLCA and SQLDA ?
    2.     What is a mutating table ?
    3.     What are indicator variables and how are they used ?
    4.     What are the components of the Oracle VARCHAR type and how should such a structure be loaded into a C Char type ?
    5.     Why would you use the ‘ALTER SESSION’ command in conjunction with the tkprof program and what is the purpose of each step ?
    ORACLE SQL QUESTIONS:
    1.0     How would you move data from one Oracle database to another Oracle database?
    2.0     How would you import data into an Oracle database from another DBMS or flat file?
    3.0     What is an Outer Join and how does the output differ from a simple join?
    4.0     What is the difference between the conditional expressions IN and EXISTS ? In what circumstances would you USE EACH.
    5.0      You cannot create a unique index on a table due to duplicate values. Describe how you find the offending row and subsequently delete it.

    1. What are the SQLCA and SQLDA ?
    SQLCA = SQL Communications area: stores status variable and error message text. manual reference
    SQLDA = SQL Descriptor Area - stores information about bind variables. manual reference
    2. What is a mutating table ?
    A table that is being modified and that you are trying to select from. Usually encountered in a before insert/update trigger when trying to select from the table that is being inserted/updated, which causes the dreaded ORA-04091 error.
    3. What are indicator variables and how are they used ?
    Used in Pro*C to tell if the table column contains the value NULL.
    4. What are the components of the Oracle VARCHAR type and how should such a structure be loaded into a C Char type ?
    varchar2 is a null-terminated string. Use Pro*C extended type VARCHAR. Manual Reference
    5. Why would you use the "ALTER SESSION" command in conjunction with the tkprof program and what is the purpose of each step ?
    Use alter session to set tracing on for your session:
    alter session set sql_trace = true ;
    this will create a trace file in the user dump destination
    (select value from v$parameter where name = 'user_dump_dest'). Use tkprof to format the trace file.
    1.0 How would you move data from one Oracle database to another Oracle database?
    Export / Import Oracle utility, Database link and INSERT ... SELECT ..., Database link and COPY command, save to flat file and use SQL*Loader, transportable tablespaces, database "cloning" by copying database files over to a new server and creating a new instance based on those files. List of manuals look up CREATE DATABASE LINK in the SQL Reference, COPY command in the SQL*Plus reference, Export/Import or SQL*Loader in the Utilities manual.
    2.0 How would you import data into an Oracle database from another DBMS or flat file?
    SQL*Loader Oracle Utility
    3.0 What is an Outer Join and how does the output differ from a simple join?
    An example is worth 1000 words.
    SQL> select * from emp ;
       EMP_NO EMP_NAME     DEPT_NO
            1 SMITH              1
            2 JONES              1
            3 BROWN              2
            4 BOND               5
    SQL> select * from dept ;
      DEPT_NO DEPT_NAME
            1 SALES
            2 MARKETING
    SQL> -- inner or "ordinary" join
    SQL> select a.emp_name, b.dept_name
      2  from emp a, dept b
      3  where a.dept_no = b.dept_no ;
    EMP_NAME   DEPT_NAME
    SMITH      SALES
    JONES      SALES
    BROWN      MARKETING
    SQL> -- outer join
    SQL> select a.emp_name, b.dept_name
      2  from emp a, dept b
      3  where a.dept_no = b.dept_no (+) ;
    EMP_NAME   DEPT_NAME
    SMITH      SALES
    JONES      SALES
    BROWN      MARKETING
    BOND5.0 You cannot create a unique index on a table due to duplicate values. Describe how you find the offending row and subsequently delete it.
    Using exceptions clause of enable constraint
    ALTER TABLE employees
    ENABLE VALIDATE CONSTRAINT emp_manager_fk
    EXCEPTIONS INTO exceptions ;
    Find rowids in exceptions table and use those rowids to delete the "bad" data. See SQL reference on alter table for more details.

  • Problem with Java 5 and Oracle 10g JDBC driver

    Hi All,
    Currently we upgrade our web application to Java 5 and Oracle 10.2 JDBC driver. And we encountered a bug, when the user entered the information through UI and data didn't store into database (Oracle 9i). The problem is that this bug is not happend so often maybe once a day and this did not happen before we upgraded to Java 5 and Oracle 10.2 JDBC driver. Does anyone encounter the same problem ? Is this Java 5 problem or Oracle JDBC driver problem ?
    Thanks,

    sounds like a database problem...
    Are you using a driver version that's supported for your database engine?
    What else did you change? We once ran into a major bug in our application that had for 5 years been masked by performance problems in our hardware and infrastructure.
    Once those were resolved the bug showed itself and caused tens of thousands of records to be erroneously inserted into our database every day.
    It's certainly NOT a problem with your JVM (if it's a decent one, like the Sun implementation).
    So it's either your database, your driver, your network (dropping packets???), or your application.
    The upgrade may just have exposed something that was already there.

  • Performanceproblem with WL6.1 JDBC and Oracle

    Hi!
    I have a big performance-problem using wl6.1, jdbc and oracle.
    My Server is sending a Vector with NodeBeans via JDBC to a OracleDB. The answer
    comes immediately with the timeout.
    Why is the EJB waiting for the timeout?
    Is it a problem of configuration?
    Thanks
    Thomas

    Hi Sree,
    here I send You the class with the main problem. The call queryDataSet.refresh();
    is the timeconsuming part.
    We are using WL6.1sp2, Oracle 8.1.7 with classes12. In our environment we can
    not use connectionpools.
    It comes back with a timeout AND the data. Calling it again immediately it takes
    2/3 of the time the timeout is set.
    Do You have a fine solution?
    Thanks
    Thomas
    package ppif.db;
    import java.rmi.*;
    import ppif.bo.*;
    import java.util.*;
    import com.borland.dx.dataset.*;
    import com.borland.dx.sql.dataset.*;
    import java.math.*;
    public class connector {
         private ppif.mapping.NodeDescriptions nodeDescriptions;
         public connector(ppif.mapping.NodeDescriptions nodeDescriptions) {
              this.nodeDescriptions = nodeDescriptions;
         public connector() {
              this.nodeDescriptions = nodeDescriptions;
         public Vector fetchNodes(ppif.bo.Node filterNode) throws RemoteException {
              String childClassName = null;
              Vector nodeVector = new Vector();
              Node node = null;
              if (nodeDescriptions == null) throw new RemoteException("nodeDescriptions ==
    null");
              // childClassName zu gegebenen filterNode ermitteln
              if (filterNode.getClassName().equals("DefaultRoot")) childClassName = "ST";
              if (filterNode.getClassName().equals("PrismaProjectsRoot")) childClassName =
    "PrismaProjects";
              if (childClassName == null) throw new RemoteException("Zum übergebenen filterNode
    wurde kein chlidClassName gefunden.");
              if (nodeDescriptions.getNodeDescription(childClassName) == null) throw new RemoteException("Für
    die ChildClass "+childClassName+" ist kein Mapping definiert.");
              // Vector mit Child-Knoten erzeugen durch DB-Zugriff
              ppif.mapping.NodeDescription nodeDescription = nodeDescriptions.getNodeDescription(childClassName);
    Database database = new Database();
    ParameterRow parameterRow = null;
    Column column = null;
    QueryDataSet queryDataSet = new QueryDataSet();
    // DB-Connect generieren
    database.setConnection(new com.borland.dx.sql.dataset.ConnectionDescriptor(nodeDescription.dbUrl,
    nodeDescription.dbUser, nodeDescription.dbPassword, false, "oracle.jdbc.driver.OracleDriver"));
    int queryCount = 0;
    // Schleife über alle queries der childKlasse, gemäss Mapping
    for (Iterator it = nodeDescription.mappingQueries.iterator(); it.hasNext();
                   ppif.mapping.MappingQuery mappingQuery = (ppif.mapping.MappingQuery)it.next();
                   String queryString = mappingQuery.getQueryString();
                   parameterRow = mappingQuery.getParameterRow();
                   // ParameterRow mit Input-Werten füllen
                   for (int i=0; i<parameterRow.getColumnCount(); i++) {
                        String columnName = parameterRow.getColumn(i).getColumnName();
                        String filterAttributeName = columnName;
                        Object filterAttributeValue = filterNode.getAttribute(filterAttributeName).getVal1();
                        switch (parameterRow.getColumn(i).getDataType()) {
                             case com.borland.dx.dataset.Variant.BIGDECIMAL:
                                  BigDecimal val = (BigDecimal)filterAttributeValue;
                                  parameterRow.setBigDecimal(i, val);
                                  break;
                             case com.borland.dx.dataset.Variant.STRING:
                                  parameterRow.setString(i, (String)filterAttributeValue);
                                  break;
                             default:
                                  throw new RemoteException("Unbekannter Datentyp");
                   // Query generieren
                   queryDataSet.setQuery(new com.borland.dx.sql.dataset.QueryDescriptor(database,
    queryString, parameterRow, false, Load.ALL));
                   // DB-Verbindung öffnen
                   queryDataSet.open();
                   // Rolle setzen
                   if (nodeDescription.dbRole != null) {
                        java.sql.Statement setRole;
                        String roleName = nodeDescription.dbRole;
                        String rolePwd = nodeDescription.dbRolePassword;
                        try {
                             java.sql.Connection jdbcConnection = database.getJdbcConnection();
                             setRole = jdbcConnection.createStatement();
                             setRole.execute("SET ROLE " + roleName + " IDENTIFIED BY " + rolePwd);
                        } catch (java.sql.SQLException exception) {
                             throw new RemoteException(exception.getMessage());
                        } catch (Exception exception) {
                             throw new RemoteException(exception.getMessage());
                   // Query ausführen
                   queryDataSet.refresh();
                   // Datensätze in Node-Objekte umwandeln
                   int columnCount = queryDataSet.getColumnCount();
                   String columnArray[];
                   columnArray = queryDataSet.getColumnNames(columnCount);
                   for(queryDataSet.first(); queryDataSet.inBounds(); queryDataSet.next()) {
                        Node rNode = nodeDescriptions.createNodeInstance(childClassName);
                        // Abfrageergebnissen in eine Attributliste übertragen
                        for (int i=0; i<columnCount; i++) {
                        nodeVector.add(rNode);
                   queryCount++;
              return nodeVector;
         public ppif.mapping.NodeDescriptions getNodeDescriptions() {
              return nodeDescriptions;
         public void setNodeDescriptions(ppif.mapping.NodeDescriptions nodeDescriptions)
              this.nodeDescriptions = nodeDescriptions;
    "Sree Bodapati" <[email protected]> wrote:
    hi Thomas,
    please post more detail on what your code is doing. if possible a code
    snippet/error messages/thread dump
    sree
    "Thomas Eberhard" <[email protected]> wrote in message
    news:[email protected]...
    Hi!
    I have a big performance-problem using wl6.1, jdbc and oracle.
    My Server is sending a Vector with NodeBeans via JDBC to a OracleDB.
    The
    answer
    comes immediately with the timeout.
    Why is the EJB waiting for the timeout?
    Is it a problem of configuration?
    Thanks
    Thomas

  • Urgent help please, I made an file with the size 1024x768, then i made two folios, one for retina 2048x1536 and one for non retina 1024x768, i have alot of video content in it, everything works perfect on my retina ipad, but when i open it on ipad 2 an er

    Urgent help please, I made an file with the size 1024x768, then i made two folios, one for retina 2048x1536 and one for non retina 1024x768, i have alot of video content in it, everything works perfect on my retina ipad, but when i open it on ipad 2 an error appears on the pages with video content?

    its in german:
    der Vorgang könnte nicht abgeschlossen werden.
    something like the process coundnt be completed

  • Just bought Elements 13. Input serial number (starting 1057), which is not recognised and the installation stalls here. Urgent help please...

    Just bought Elements 13. Input serial number (starting 1057), which is not recognised and the installation stalls here. Urgent help please...

    Maryrhire910 I am sorry that you are facing difficulty downloading and installing Photoshop Elements 12.  Are you downloading the installation files from Download Photoshop Elements products | 13, 12, 11, 10?  If so what specific error are you receiving?

  • HELP WITH IPHONE 4S IPHONE URGENT HELP PLEASE?

    IPHONE URGENT HELP PLEASE?
    for the whole day my network has been 'Searching...'
    i have tried airplane mode on and off, turning my phone on and off and network reset and taking sim in and out.
    so i backed up my phone and restored to factory settings as i don't think i did the option of choosing manually select a carrier.
    my network is still 'searching...' and it won't let my wifi to allow me to activate my iphone. i have tried to connect to itunes and it still won;t work.
    i keep getting a message about no activation server.
    this is a new iphone. i got it replaced on saturday.
    PLEASE SOMEONE HELP ME!!!!!!!!!!!!!!!!!!!!!!!!!!!

    Hello,
    If this is a new iPhone then you will have free access, as all iPhones come with it, to Apple support. I would have them take care of an issue like this.
    Hope this helps.
    Regards,
    Jake

  • Load XML in intranet ? urgent help please...

    Dear friends, I need urgent help: I have a CAYIN screen (which lets me display evetns, etc) and gives me the option of loading/displaying a FLASH (SWF) file, well, I need this SWF to load some XML data ("texto.xml") but  seems that when the CAYIN program which executes flash, does not allow the SWF to find the XML in the same folder...
    Then I tried many ways to load the XML file with no success till now. Some tries are :
    obj_xml.load("\\192.168.0.100\media\texto.xml")
    obj_xml.load("\media\texto.xml")
    obj_xml.load("texto.xml")
    obj_xml.load("../media/texto.xml")
    obj_xml.load("\\media\texto.xml")
    obj_xml.load("file:\\192.168.0.100\media\texto.xml")
    obj_xml.load("..\\192.168.0.100\media\texto.xml")
    I guess I am writting something wrong or forgetting something. Would anyone please help me ? because these files are in an internal server "192.168.0.100" (intranet).
    Urgent help please, thanks in advance,

    if the swf is in a directory with subdirectory media which contains texto.xml, use:
    obj_xml.load("media/texto.xml")

  • My ipod touch is disabled for 22 million minutes and I want to fix it but I dont want to lose my pictures and everything else. Help please

    my ipod touch is disabled for 22 million minutes and I want to fix it but I dont want to lose my pictures and everything else. Help please I dont remember the last time I updated it. Idk I think its been a year in an half since I known about it being disabled. What do I do? Im scared to restore it because I dont want to lose my stuff.

    You have to restore and thus erase your iPod. that is how it works.
    Place the iOS device in Recovery Mode and then connect to your computer and restore via iTunes. The iPod will be erased.
    iOS: Wrong passcode results in red disabled screen                        
    If recovery mode does not work try DFU mode.                       
    How to put iPod touch / iPhone into DFU mode « Karthik's scribblings       
    For how to restore:
    iTunes: Restoring iOS software
    To restore from backup see:
    iOS: How to back up    
    If you restore from iCloud backup the apps will be automatically downloaded. If you restore from iTunes backup the apps and music have to be in the iTunes library since synced media like apps and music are not included in the backup of the iOS device that iTunes makes.
    You can redownload iTunes purchases by:
    Downloading past purchases from the App Store, iBookstore, and iTunes Store       
    Photos
    - If they are in an iPod backup then restore from that backup. See the restore topic of:
    iOS: How to back up
    - If they are in the iTunes backup then get them from the backup by:
    Recover iPhone, iPad or iPod photos from backups with Picturescue
    - If you used PhotoStream then try getting them from your PhotoStream. See that topic of:
    iOS: Importing personal photos and videos from iOS devices to your computer

  • My Creative Cloud wont show the Apps, it says download Error contact support. And on the Home Menu on the creative cloud for MAC desktop it just loads and loads and never stops. Help please!!

    My Creative Cloud wont show the Apps, it says download Error contact support. And on the Home Menu on the creative cloud for MAC desktop it just loads and loads and never stops. Help please!!

    Hypesuh I would recommend reviewing both Error downloading Creative Cloud applications - http://helpx.adobe.com/creative-cloud/kb/error-downloading-cc-apps.html and Creative Cloud app doesn't open and hangs on spinning progress wheel - http://helpx.adobe.com/creative-cloud/kb/creative-cloud-app-doesnt-open.html as it appears both documents are applicable towards the difficulties which you are currently facing.

  • HT201272 Tried to re-download previous music purchases, but the download button reads 'Downloaded' and is inactive. Help please. Thanks

    Tried to re-download previous music purchases, but the download button reads 'Downloaded' and is inactive. Help please. Thanks

    Welcome to Apple Support Communities
    As you know how to open the iTunes Media folder, go to this folder and open iTunes. Then, go to Apps in iTunes and drag the IPA file of the app you want to show up to the iTunes window, so it should be added.
    If it doesn't work, delete the IPA, empty the Trash and you will be able to download the application.
    If a post solved your question or helped you, mark it as solved or helpful before posting a reply. Doing this, you will avoid that your own post is marked as solved or helpful. You won’t receive any point if you mark your own post as solved or helpful. Also, you won’t be rewarding the user who solved your question and you will help other users find the answer if you mark the correct reply

  • I am trying to download Firefox 3.6 to use on my Mac OS X version 10.3.9. Three attempts and I continue to get "mounting failed" and "corrupt image". Help please?

    I am trying to download Firefox 3.6 to use on my Mac OS X version 10.3.9. Three attempts and I continue to get "mounting failed" and "corrupt image". Help please?

    Firefox 3.6 requires at least OS X 10.4, the last version of Firefox that worked on OS X 10.3.9 was Firefox 2.0.0.20 which is available from ftp://ftp.mozilla.org/pub/mozilla.org/firefox/releases/2.0.0.20/mac/

  • After Mac OS X 10.6.3 upgrade can't access Yahoo mail and repeatedly get message ""Sorry, we are over capacity. Please wait a moment and try again." Help, please,

    After Mac OS X 10.6.3 upgrade can't access Yahoo mail and repeatedly get message ""Sorry, we are over capacity. Please wait a moment and try again." Help, please.

    Did you run all the software updates after the 10.6.3 update, especially this one which will bring you up to 10.6.8.
    Mac OSX 10.6.8 V1.1 Combo update
    Run software update, starting with the one above.
    Then call your provider and ask them what is going on. They have probably changed POP to IMAP, 10.6.8 supports IMAP

  • Hi im having problems with my internet and email ive reset the network even with my wifi on ive also turned off and on airplane mode help please thank you

    hi im having problems with my internet and email Ive reset the network even with my WiFi on Ive also turned off and on airplane mode help please thank you

    hi Ive reset my network toggled the airplane on and off and turned off my carrier off then turned my phone off and turned my carrier back on but still problem persists

Maybe you are looking for

  • Family sharing is not working

    So today I downloaded IOS 8 on both devices, Ipod 5th generation and Iphone 4S. they both have different accounts. i set up the family sharing on both devices and they were both set up. i went on the Ipod 5th generation to download the previous purch

  • Can you restrict APEX users to a single browser session?

    I'm using APEX3.2.1 Is there a package,function, view or table in APEX that can be checked to see if a user_id already has an active session (one that hasn't been purged yet). I wish to restrict each user to a single active browser session. Cheers df

  • Problems working with source files

    Just downloaded the new 1343 release. Really like the product. But ... working with source files in SQL Developer is my worst nightmare. When I open a source file either from SQL Worksheet or from File/Open menu my PC freezes for an extended period o

  • Help with Audigy 2 Zs and crackling sound ..

    For the past 5 months or so ( not long after I got the product ) I have been getting this periodic issue with the sound ... I'll start to notice a popping and crackling sound coming from the left channel when loud sounds issue from the game ( multipl

  • BlazeDS Database pub/sub

    Wanting to push new data rcvd in my oracle database to my flex page w/o refreshing.  Can I use BlazeDS to subscribe and push data from a database to Flex or is there a better technology for this?