Best way to attack this problem

I am trying to make a hot backup java program for Oracle. I am new to both jdbc and java in general.
If my entry point class is
// file connectme.java
package cm;
import java.sql.*; // Package for JDBC classes.
import java.util.*;
public class connectme
public static void main(String[] args)
connClass conn1 = new connClass(); // this class makes the connection to Oracle
hotBackUp hotBackUp1 = new hotBackUp();
hotBackUp1.getDBA_Data_Files();
// end
the class connClass looks like
// in file connClass.java
package cm;
import java.sql.*; // Package for JDBC classes.
import java.util.*;
public class connClass{
// Database Connection Object
Connection m_connection = null;
public connClass(){
System.out.println("in connectme");
this.dbConnection(); // Sets up DB connection
if (m_connection != null){
System.out.println("we connected");
else{
System.out.println("damit not connected");
public void dbConnection() {
try {
System.out.println("Trying to connect to the Database...");
DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
String l_dbConnectString =
"(DESCRIPTION=(ADDRESS=(HOST="+ConnectionParams.s_hostName+")"+
"(PROTOCOL=tcp)(PORT="+ConnectionParams.s_portNumber+"))"+
"(CONNECT_DATA=(SID="+ConnectionParams.s_databaseSID+")))";
m_connection = DriverManager.getConnection(
"jdbc:oracle:thin:@"+l_dbConnectString,
ConnectionParams.s_userName, ConnectionParams.s_password);
m_connection.setAutoCommit(false);
System.out.println("Connected to "+ConnectionParams.s_databaseSID+
" Database as "+ConnectionParams.s_userName+".");
} catch(SQLException ex){ // Trap SQL errors
System.out.println("Error in Connecting to the Database "+ex.toString());
// end
and hotBackUp looks like
// in file hotBackUP.java
package cm;
import java.sql.*; // Package for JDBC classes.
import java.util.*;
public class hotBackUp{
// default constructor
public hotBackUp(){}
* This method retrieves data from dba_data_files
public void getDBA_Data_Files(){
try{
System.out.println("Trying to get dba_data_files information");
Statement l_stmt = conn1.m_connection.createStatement();
ResultSet l_resultSet = l_stmt.executeQuery(
"select TABLESPACE_NAME,FILE_NAME from dba_data_files "+
"order by TABLESPACE_NAME");
while(l_resultSet.next()){
System.out.println(l_resultSet.getString(1) ); // Tablespace Name
System.out.println(l_resultSet.getString(2) ); // File Name
l_stmt.close(); // Close the Statement
} catch(SQLException ex) {  // Trap SQL Errors
int i = ex.getErrorCode();
System.out.println("ERROR ORA-"+i);
// end
The issue I am having is hotBackUp.getDBA_Data_Files cannot find the conn1.m_connection.createStatemet() the compile fails. How can class hotBackUp know about the other class? Should I use a Interface or Inner Class?

And even nicer is to extend connClass as a base class for hotBackUp.
// file connectme.java
package cm;
public class connectme {
  public static void main(String[] args) {
    hotBackUpSubClass hotBackUpSub2 = new hotBackUpSubClass();
    hotBackUpSub2.getDBA_Data_Files();
    hotBackUpSub2.closeConnection();
}// end
// in file hotBackUpSubClass.java
package cm;
import java.sql.*; // Package for JDBC classes.
*  This class now extends connClass, so we do without
*  the aggregation syntax.  Everything we handled for
*  the connection object in the hotBackUp regular class,
*  has been inherited from connClass in this new variation
*  of hotBackUp.
public class hotBackUpSubClass extends connClass {
   * default constructor
  public hotBackUpSubClass(){
    super();
   * This method retrieves data from dba_data_files
  public void getDBA_Data_Files(){
    try{
      System.out.println("Trying to get dba_data_files information");
      Statement l_stmt = getConnection().createStatement();
      ResultSet l_resultSet = l_stmt.executeQuery(
        "SELECT username, authID FROM webportal.webuser" );
//        "select TABLESPACE_NAME,FILE_NAME from dba_data_files "+
//        "order by TABLESPACE_NAME" );
      while(l_resultSet.next()){
        System.out.println( l_resultSet.getString(1) ); // Tablespace Name
        System.out.println( l_resultSet.getString(2) ); // File Name
      l_stmt.close(); // Close the Statement
    } catch(SQLException ex) { // Trap SQL Errors
      int i = ex.getErrorCode();
      System.out.println("ERROR ORA-"+i);
}// endHere is the raw text of the whole thing again.
// file connectme.java
package cm;
public class connectme {
public static void main(String[] args) {
* we didn't follow this train of thought...
*connClass conn1 = new connClass();
* This class makes its own connection to Oracle
* from within itself, by using an instance of
* your connClass object ...aggregation ??
hotBackUp hotBackUp1 = new hotBackUp();
hotBackUpSubClass hotBackUpSub2 = new hotBackUpSubClass();
* This is now a self connecting 'entity',
* which performs a single database activity.
hotBackUp1.getDBA_Data_Files();
hotBackUpSub2.getDBA_Data_Files();
// Remember to also close the database connection
hotBackUp1.closeConnection();
hotBackUpSub2.closeConnection();
}// end
// in file connClass.java
package cm;
import java.sql.*; // Package for JDBC classes.
public class connClass{
* Database Connection Object.
* This is what we are encapsulating, we need to
* provide convenience methods to let outsiders
* make use of its 'self contained' existence.
private Connection m_connection = null;
public connClass(){
System.out.println("in connectme");
this.dbConnection(); // Sets up DB connection
if (m_connection != null){
System.out.println("we connected");
else{
System.out.println("What a surprise, not connected!");
* We needed a convenience method to grab the connection.
public Connection getConnection() {
return m_connection;
* We needed a convenience method to close the connection.
* We politely call this when we are done with this object.
public void closeConnection() {
if(m_connection != null) {
try {
m_connection.close();
} catch(SQLException ex){ // Trap SQL errors
System.out.println(
"Error closing Connecting to the Database " +
ex.toString()
public void dbConnection() {
try {
System.out.println("Trying to connect to the Database...");
* DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
* Hmmm, the above gives me grief ...this is another option.
try {
Class.forName( "oracle.jdbc.driver.OracleDriver" );
} catch ( ClassNotFoundException e )
{ System.out.println( "Could not load OracleDriver" ); }
// I showed you my raw url here, make sure yours is correct.
String /** -- IP:PORT:SID */
l_dbConnectString = "127.0.0.1:1521:GumB",
s_password = "guest",
s_userName = "portalguest";
"(DESCRIPTION=(ADDRESS=(HOST="+ConnectionParams.s_hostName+")"+
"(PROTOCOL=tcp)(PORT="+ConnectionParams.s_portNumber+"))"+
"(CONNECT_DATA=(SID="+ConnectionParams.s_databaseSID+")))";
m_connection = DriverManager.getConnection(
"jdbc:oracle:thin:@"+l_dbConnectString,
/**ConnectionParams.*/s_userName,
/**ConnectionParams.*/s_password
m_connection.setAutoCommit(false);
// System.out.println("Connected to "+ConnectionParams. s_databaseSID+
// " Database as "+ConnectionParams.s_userName+".");
} catch(SQLException ex){ // Trap SQL errors
System.out.println("Error in Connecting to the Database "+ex.toString());
}// end
// in file hotBackUpSubClass.java
package cm;
import java.sql.*; // Package for JDBC classes.
* This class now extends connClass, so we do without
* the aggregation syntax. Everything we handled for
* the connection object in the hotBackUp regular class,
* has been inherited from connClass in this new variation
* of hotBackUp.
public class hotBackUpSubClass extends connClass {
* default constructor
public hotBackUpSubClass(){
super();
* This method retrieves data from dba_data_files
public void getDBA_Data_Files(){
try{
System.out.println("Trying to get dba_data_files information");
Statement l_stmt = getConnection().createStatement();
ResultSet l_resultSet = l_stmt.executeQuery(
"SELECT username, authID FROM webportal.webuser" );
// "select TABLESPACE_NAME,FILE_NAME from dba_data_files "+
// "order by TABLESPACE_NAME" );
while(l_resultSet.next()){
System.out.println( l_resultSet.getString(1) ); // Tablespace Name
System.out.println( l_resultSet.getString(2) ); // File Name
l_stmt.close(); // Close the Statement
} catch(SQLException ex) { // Trap SQL Errors
int i = ex.getErrorCode();
System.out.println("ERROR ORA-"+i);
}// end
// in file hotBackUp.java
package cm;
import java.sql.*; // Package for JDBC classes.
public class hotBackUp{
* Now here we can treat that connection object like
* an entity, one that knows how to do its own work.
connClass connectionObj;
* default constructor
* A good place to instantiate the connection entity.
public hotBackUp(){
connectionObj = new cm.connClass();
* This lets outsiders signal that they are through with hotBackUP,
* so that it can tell the database connection to close.
* You get a bunch of rogue connections laying around in
* your system if you leave these hanging around open.
public void closeConnection() {
connectionObj.closeConnection();
* This method retrieves data from dba_data_files
public void getDBA_Data_Files(){
try{
System.out.println("Trying to get dba_data_files information");
Statement l_stmt = connectionObj.getConnection().createStatement();
ResultSet l_resultSet = l_stmt.executeQuery(
"SELECT username, authID FROM webportal.webuser" );
// "select TABLESPACE_NAME,FILE_NAME from dba_data_files "+
// "order by TABLESPACE_NAME" );
while(l_resultSet.next()){
System.out.println( l_resultSet.getString(1) ); // Tablespace Name
System.out.println( l_resultSet.getString(2) ); // File Name
l_stmt.close(); // Close the Statement
} catch(SQLException ex) { // Trap SQL Errors
int i = ex.getErrorCode();
System.out.println("ERROR ORA-"+i);
}// end

Similar Messages

  • My Iphoto libary is full and will not acept new photos, what is the best way to solve this problem without losing old photos

    Hi
    My Iphoto libary is full and wil not acept new photos what is the best way to solve this problem without losing the old photos?

    Here is a relevant discussion to your situation:
    https://discussions.apple.com/thread/2640787?start=0&tstart=0

  • I have iphone 5, after upgrading it to iOS7, front is working find unfortunately rear camera became blurred, what is the best way to fix this? Looking forward to the best solution of this problem.

    I have iphone 5, after upgrading it to iOS7, front is working find unfortunately rear camera became blurred, what is the best way to fix this? Looking forward to the best solution of this problem.

    WORKAROUND FOUND ! Download and install "Awesome Camera" app and take a picture with that app. After 1-2 seconds of standby, it will work. Then you can go back to default Camera app which would work again.Please let me know

  • What's the best way for reading this binary file?

    I've written a program that acquires data from a DAQmx card and writes it on a binary file (attached file and picture). The data that I'm acquiring comes from 8 channels, at 2.5MS/s for, at least, 5 seconds. What's the best way of reading this binary file, knowing that:
    -I'll need it also on graphics (only after acquiring)
    -I also need to see these values and use them later in Matlab.
    I've tried the "Array to Spreadsheet String", but LabView goes out of memory (even if I don't use all of the 8 channels, but only 1).
    LabView 8.6
    Solved!
    Go to Solution.
    Attachments:
    AcquireWrite02.vi ‏15 KB
    myvi.jpg ‏55 KB

    But my real problem, at least now, is how can I divide the information to get not only one graphic but eight?
    I can read the file, but I get this (with only two channels):
    So what I tried was, using a for loop, saving 250 elements in different arrays and then writing it to the .txt file. But it doesn't come right... I used 250 because that's what I got from the graphic: at each 250 points it plots the other channel.
    Am I missing something here? How should I treat the information coming from the binary file, if not the way I'm doing?
    (attached are the .vi files I'm using to save in the .txt format)
    (EDITED. I just saw that I was dividing my graph's data in 4 just before plotting it... so It isn't 250 but 1000 elements for each channel... Still, the problem has not been solved)
    Message Edited by Danigno on 11-17-2008 08:47 AM
    Attachments:
    mygraph.jpg ‏280 KB
    Read Binary File and Save as txt - 2 channels - with SetFilePosition.vi ‏14 KB
    Read Binary File and Save as txt - with SetFilePosition_b_save2files_with_array.vi ‏14 KB

  • What is the best way to approach this?

    "php 5.3.x + oracle 11g R2 XE 11.2.x.x"
    Hello everyone,
    I'm quite new to oracle (2-4 months) and php(2 weeks).
    I have one query with results that needs to be reused in several parts of my website. I can't seem to find the equivalent of the mysql_data_seek in Oracle. I wanted to reset the cursor/pointer of oci_fetch($result) so that I can scroll the result again.
    So far this are what I have come up:
    A. On first fetch put the the results in a php array and call the array later on.
    B. Do the query again.
    C. Keep on looking for a mysql_data_seek equivalent and fail.
    I'm leaning towards option 'A' but I just wanted to consult the experts.
    Thank you!

    Moved to: What is the best way to approach this? (oci_fetch problem)
    Edited by: m.davide on Oct 23, 2012 2:21 AM
    Edited by: m.davide on Oct 23, 2012 2:22 AM

  • I would like to display what's on my Mac Pro monitor on my iPad with as little latency as possible. What's the best way to do this?

    I would like to display what's on my Mac Pro monitor on my iPad with as little latency as possible. What's the best way to do this?

    Your image history (if I understand you properly) is stored in your catalog file, and nowhere else, and so it is only on a single drive.
    Do you mean you have edited photos on multiple drives? This isn't a problem for Lightroom at all, the software doesn't care, and you can leave things just the way they are. But if it bothers you for some reason, you can move the photos to a single drive if you want. In Lightroom select the desired photos or folders (it's easier to do this using Folders) and drag them to the desired drive.
    Alternative if you will be moving lots of folders: Adobe Lightroom - Find moved or missing files and folders

  • I have problem with my ipad when set up ipad asked to activation but i cant remember my apple id that i used to setup.now i can not open it .Is there any way to fix this problem?

    I have problem with my ipad when set up ipad asked to activation but i cant remember my apple id that i used to setup.now i can not open it .Is there any way to fix this problem?

    Hello Abdo_Zain,
    I would be concerned too if I was not able to gain access to my iPad.  If you are unsure what your Apple ID is, you can find the steps in this article:
    Apple ID: How to find your Apple ID
    http://support.apple.com/kb/HT5625
    You can reset a forgotten Apple ID password by going to the following link:
    Apple - iForgot
    https://iforgot.apple.com
    Also, you may be able to skip the step of entering your Apple ID if you are setting up the iPad for the first time.
    Thank you for using Apple Support Communities.
    Best,
    Sheila M.

  • When I attempt to open a PDF file I saved from a website, I get the message "There was an error opening this document. The file is damaged and could not be repaired." Is there any way to correct this problem?

    When I attempt to open a PDF file I saved from a website using Safari, I get the message "There was an error opening this document. The file is damaged and could not be repaired." When I save the same PDF file using FireFox it opens up immediately. Is there any way to correct this problem with Safari?

    Back up all data.
    Triple-click the line of text below to select it, the copy the selected text to the Clipboard (command-C):
    /Library/Internet Plug-ins
    In the Finder, select
    Go ▹ Go to Folder
    from the menu bar, or press the key combination shift-command-G. Paste into the text box that opens (command-V), then press return.
    From the folder that opens, remove any items that have the letters “PDF” in the name. You may be prompted for your login password. Then quit and relaunch Safari, and test.
    The "Silverlight" web plugin distributed by Microsoft can also interfere with PDF display in Safari, so you may need to remove it as well, if it's present.
    If you still have the issue, repeat with this line:
    ~/Library/Internet Plug-ins
    If you don’t like the results of this procedure, restore the items from the backup you made before you started. Relaunch Safari again.

  • I bought my iphone 5s a week before and now its volume "up" button is not working when pressed.Does anybody know what to do to make it work?I have a one year warranty.Should i give it to apple retail shop or is there any way to solve this problem?

    I bought my iphone 5s a week before and now its volume "up" button is not working when pressed.Does anybody know what to do to make it work?I have a one year warranty.Should i give it to apple retail shop or is there any way to solve this problem?

    IF it is a manufacturing defect and you bought the device from Apple or an authorized Apple retailer, then take it into Apple.

  • When I put in my earphones to listen to music the sound isn't clear and I have to push and hold them in it in order for it to be. It's not the earphones because I use them in my laptop and they work fine. Is there a way to fix this problem?

    Whenever I put my earphones into my iPod Touch 2g the music isn't clear and I have to push and hold them in order to hear the song normally. It isn't the earphones because I tried another pair, that worked fine, and there was still no difference. I also use the same pair of earphones in my laptop and it sounds great. Is there a way to fix this problem without having to buy a brand new iPod touch? Do I need to clean it or something? And if so, how would I go about doing that? Thanks!

    - Try cleaning out/blowing out the headphone jack. Try inserting/removing the plug a dozen times or so.
    If still problem that indicates you have a bad headphone jack.
    Apple will exchange your iPod for a refurbished one for this price. They do not fix yours. Likely not worth it for your old 2G iPod
    Apple - iPod Repair price                  
    A third-party place like the following will replace the jack for less. Google for more.
    iPhone Repair, Service & Parts: iPod Touch, iPad, MacBook Pro Screens
    Replace the jack yourself
    iPod Touch Repair – iFixit

  • My old computer is dying and I want to transfer my account to my new computer.  I will not be using the old computer at all.  What is the best way do do this?

    I want to stop using my old computer completely and transfer my itunes account to my new computer.  What is the best way to do this?

    A simple search

  • My Macbook pro was stolen 09/12, the police just returned it to me. I want to remove all the data and start over. Format the drive's etc. I have windows 7 on 1 partion and mountain lion OSX on the apple partition. How is the best way to do this?

    My Macbook pro was stolen 09/12, the police just returned it to me. I want to remove all the data and start over. Format the drive's etc. I have windows 7 on 1 partion and mountain lion OSX on the apple partition. How is the best way to do this?

    Have a look here...
    what-to-do-when-your-hard-drive-is-full.html

  • TS1314 I have lots of organized photos on my PC and I want to keep them organized to sync to ipad.... how is the best way to do this?

    I have spent a lot of time saving, organizing and arranging photos (for the last 7 years) on my PC, and would like to know the best way to transfer these, AND MAINTAIN THE ORGANIZATION OF THE FOLDERS, to my new ipad (and later, my iphone). I have a really good system, and I do not want to have to do it all over again, on the ipad. I DO NOT want to subscribe to another monthly service fee (i.e. the iCloud) but DO have iTunes on my PC.
    What is the simplest method to do this ?  I have tried synching, but, each time have lost photos (on my ipad) OR have had NO ORGANIZATION AT ALL to the photos once synced.  I have all these photos (5.6gb) in the My Pictures folder, then subdivided into years, then subdivided into events and months within the years.  So, my transfer of the My Picures folder, completely transfers all of them, but with NO further organization.  Again, I have spent years doing this, and don't want to have to re-invent the wheel. 
    Can someone advise (or even better, lead me to a youtube video) that accurately shows the best way to do this ?
    Thank you, in advance, for your help.
    p.s.  I particularly enjoy Dan Nations very informative articles on how to get the best from my products.  And, wish Apple would explain "how it works" regarding the syncing methods on the Operating System.  It is the only thing I "don't get" about using my iPad..... meanwhile I LOVE my new mini ! ! ! ! ! ! ! thanks Apple, for keeping things simple.... Please don't change that !

    Correct, it will only be one-level, the Photos app doesn't support sub-albums - the sub-folders photos will be included in the parent's album.
    If you select My Pictures at the top of the Photos tab when syncing, then you should get an album for each folder that is directly under it - so if I understand correctly what you described then that would mean an album for 2013, one for 2012 etc. And each of those should include all the photos in the subfolders under it - so 2013 would include the photos from the events and months subfolders under it.
    You can't sync them separately, only the contents of the last sync remains on the iPad, by not including a folder in the next photo sync you are effectively telling iTunes that you no longer want that folder/album on the iPad so it will be removed and be replaced by the contents of the new sync (you can't delete synced photos directly on the iPad, instead they are deleted by not including them in the next sync).
    The app that I use, Photo Manager Pro, allows you to select and copy a folder (via FTP), but you would need to select each subfolder individually, which if you have a lot would be time-consuming (I think that if you select '2013' it would ignore the folders beneath it).

  • I am trying to make a pdf of a file and I need to get the file size to be no bigger than 10MB. What is the best way to do this

    I am trying to make a pdf of a file and I need to get the file size to be no bigger than 10MB. Even when I save it, the image quality at minimum the file size is 10.9 MB. What is the best way to do this

    @Barbara – What purpose is that PDF for? Print? Web?
    If web purpose, you could convert CMYK images to sRGB. That would reduce the file size as well.
    A final resort to bring down file size is:
    1. Print to PostScript
    2. Distill to PDF
    That would bring file size down even more. About 20%, depending on the images and other contents you are using, compared with the Acrobat Pro method. If you like you could send me a personal message, so we could exchange mail addresses. I could test for you. Just provide the highres PDF without any downsampling and transparency intact. Best provide a PDF/X-4.
    I will place the PDF in InDesign, print to PostScript, distill to PDF.
    Uwe

  • HT1451 I need to move my library from my old computer to my new laptop. What's the best way to do this?

    I need to move my library from my old computer to my new laptop (Windows 8). What's the best way to do this?

    These are two possible approaches that will normally work to move an existing library to a new computer.
    Method 1
    Backup the library with this User Tip.
    Deauthorize the old computer if you no longer want to access protected content on it.
    Restore the backup to your new computer using the same tool used to back it up.
    Keep your backup up-to-date in future.
    Method 2
    Connect the two computers to the same network. Share your <User's Music> folder from the old computer and copy the entire iTunes library folder into the <User's Music> folder on the new one. Again, deauthorize the old computer if no longer required.
    Both methods should give the new computer a working clone of the library that was on the old one. As far as iTunes is concerned this is still the "home" library for your devices so you shouldn't have any issues with iTunes wanting to erase and reload.
    I'd recommend method 1 since it establishes an ongoing backup for your library.
    If you have an iOS device that syncs with contact & calendar data on your computer you should migrate this information too. If that isn't possible create a dummy entry of each type in your new profile and iTunes should offer to merge the existing data from the device into the computer, otherwise the danger is that it will wipe the information from the device.
    If your media folder has been split out from the main iTunes folder you may need to do some preparatory work to make it easier to move. See make a split library portable.
    Should you be in the unfortunate position where you are no longer able to access your original library, or a backup of it, then see Recover your iTunes library from your iPod or iOS device for advice on how to set up your devices with a new library with the maximum preservation of data. If you don't have any Apple devices then see HT2519 - Downloading past purchases from the App Store, iBookstore, and iTunes Store.
    tt2

Maybe you are looking for

  • How to change an icon of a button

    hi guys, i want to change the icon of a button when it is click how can i do it? thanks

  • Backing up a system that is on two different volumes

    Here's what I did... I've got an ssd as my startup volume in a mac mini. Through system preferences:Accounts, I right clicked on my user (admin) account, whereby I clicked on the advanced button. Through this, I set up my user folder to be on another

  • Cant use asio4all because of beats audio

     Hello. I've been habing troubles recording audio with my HP dv7 notebook.  The problem is that mic inputs appear unavailable in the asio4all control pannel of Ableton live 9 (or any other daw), like some application is using it, and asio isnt multic

  • DISAPPEARING APPS ON HOMEPAGE

    ok here's the situation its about randomly disappearing apps from the homepage i know its a common issue but it really ****** me off that a great company like apple cant handle this glitch.... at least give me the option to delete the app and reinsta

  • CMP with Sybase ASE failing.

    Hi, I'm using CMP against Sybase ASE. I lookup the CMP from a servlet and do a create. It fails.. I've included the exception in the post.. any clues. thanks hima SEVERE: EJB5029: Exception getting ejb context : [java.lang.RuntimeException: Un able t