No access to method from within the same class

Hey there.
First I have to excuse my English for I'm german and just learning...
Ok, my problem is as follows. I have a class called JDBC_Wrapper it includes the method sendQuery(String query). When I call this method from within another class (where 'wrapper' is my instance of JDBC_Wrapper) it works fine. For example:
wrapper.sendQuery("SELECT * FROM myDataBase");
But then I have written a method called getNumRows() into my JDBC_Wrapper class.
This method should send a query through sendQuery(Strin query) but when calling getNumRows() it says: "java.sql.SQLException: [FileMaker][ODBC FileMaker Pro driver][FileMaker Pro]Unbekannter Fehler." (Unbekannter Fehler -> Unknown Exception). What could that be?
I'm using jdk2 sdk 1.4.2 with BlueJ. My database is Filemaker Pro 6. The ODBC/JDBC connector works fine.
BerndZack

This is within my JDBC_Wrapper class:
public ResultSet sendQuery(String query)
        if(connected)
            try
                Statement s = con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE);
                ResultSet rs = s.executeQuery(query);
                return rs;
            catch(Exception e)
                System.out.println(e);
        else
            //System.out.println("There is no connection to the datasource!");
        return null;
public int getNumRows()
        try
            ResultSet r;
            r = this.sendQuery("SELECT COUNT(*) FROM " + table_name); // At this line the error occurs
            r.next();
            return (int)r.getInt(1);
        catch(Exception e)
            System.out.println(e.getMessage());
            return -1;
}When I call sendQuery() from within another class it works, but calling getNumRows()
throws an exception.

Similar Messages

  • How to refer to enclosing instance from within the member class?

    Hi
    How to refer to the enclosing instance from within the member class?
    I have the following code :
    import java.awt.*;
    import java.awt.event.*;
    public class MyDialog extends Dialog
         public MyDialog(Frame fr,boolean modal)
              super(fr,modal);
              addWindowListener(new MyWindowAdapter());
         public void paint(Graphics g)
              g.drawString("Modal Dialogs are sometimes needed...",10,10);
         class MyWindowAdapter extends WindowAdapter
              public void windowClosing(WindowEvent evt)
                   //MyDialog.close(); // is this right?
    In the above code, how can I call the "close()" method of the "Dialog" class (which is the enclosing class) from the inner class?
    Thanks in advance.
    Senthil.

    Hi Senthil,
    You can directly call the outer class method. Otherwise use the following way MyDialog.this.close(); (But there is no close() method in Dialog!!)
    If this is not you expected, give me more details about problem.
    (Siva E.)

  • Accessing a method from within another method

    I am having trouble accessing a method from inside a method in the same class.
    here is my code:
    public String getAns(int ans){
    answer = ans;
    ranswer = number1 * number2;
    if(answer != ranswer){
    return "No. Please try again";
    }else{
    return "Very good!";
    genQues();
    when i run this i get an Unreachable code error pertaining to genQues();
    is this allowed in Java and is there a more practical way to go about this?
    Thank you in advance

    next time use the correct code tags to post your code.
    Think of your problem like this though.
    You write
    if( something )
    then return some value;
    else
    then return some other value.
    The returns end the method here, returning the value.
    So, if the method ended at one of these 2 statements, how do you think it'll reach genQues(); ?
    Hope this helps.

  • How to create an object within the same class???

    hi im just a newbie
    i v been always creating an object from the main class..
    but how to create an object inside the same class??
    i got main and students class
    the main got an array
    Students[] stu = new Students[]
    and i got
    stu[i] = new Students(id,name);
    i++;
    but i wanna do these things inside the Students class..
    i tried ..but i got errors.....
    how to do this
    .

    javaexpert, :)
    I really have no idea what you are trying to do since you say you've always been creating an object from the main class, yet you always want to create an object inside the same class.
    I'll assume that you have an object in the main class that you are trying to access from the Students class.
    If you are trying to access objects that are contained within the main class FROM the Students class, then know that there are two ways of doing so, one being static, and the other dynamic (look up definitions if unclear):
    1.) make the objects in the main class both static and public and access the the objects using a convention similiar to: Main.object; It's important to note that Main is the name of your main class, and object is a static object. There are better ways of doing this by using gettter/setter methods, but I'll omit that tutorial.
    2.) Create a new instance of the main class and access the objects using a similiar fashion: Main myInstance = new Main(); myInstance.myObject;
    You should really use getter and setter methods but I'll omit the code. In terms of which approach is better, step one is by far.
    I don't mean to be condecending, but you should really brush up on your programming skills before posting to this forum. This is a fundamenetal concept that you will encounter time and time again.

  • Accessing a native method from within a packaged class

    I have seen some very useful information from RPaul. However, I can not quite get it to work.
    I have a class "JNIGetUserId" that is in a package "com.services.localoptions". I am trying to call a native method from a dll. it works fine at the default package level. But not in the package. I have tried adding the "_" between each level of the directory in the h and c++ files. I also found that doing a javah at the top of the package structure it includes some information in the h file. A "_0005" shows up between each level.
    This is on Windows XP. I am also using VisualAge for Java. I also am using JDK 1.3.1.
    The source files:
    package com.services.localoptions;
    * This class provides the JNI Interface to call the
    * AD User Maintainence routines.
    * These routines are stored in the JNIGetUserIdLibrary.dll.
    * The routines are:
    * <ul>
    * <li>getUser - returns a string containing the User Id
    * <eul>
    * @author: Ray Rowehl
    * @date (10/15/2003 10:30:59 AM)
    public class JNIGetUserId
         // Load the library
         static
         try
              System.out.println("loading dll");
         System.loadLibrary("JNIGetUserIdLibrary");
         System.out.println("loaded dll");
         catch (UnsatisfiedLinkError ue)
              System.out.println("Link Error");
    * native C++ method to call getUserId routine
    public native String getUser() throws Exception;
    * This method allows us to test standalone..
    * Creation date: (10/16/2003 2:08:58 PM)
    * @param args java.lang.String[]
    public static void main(String[] args)
         try
              System.out.println("Trying method 3");
              JNIGetUserId lGUD = new JNIGetUserId();
              System.out.println(lGUD.getUser());
         catch (Exception e)
              System.out.println("Got an exception " + e);
              e.printStackTrace();
    /* DO NOT EDIT THIS FILE - it is machine generated */
    #include <jni.h>
    /* Header for class JNIGetUserId */
    #ifndef IncludedJNIGetUserId
    #define IncludedJNIGetUserId
    #ifdef __cplusplus
    extern "C" {
    #endif
    * Class: JNIGetUserId
    * Method: getUser
    * Signature: ()Ljava/lang/String;
    JNIEXPORT jstring JNICALL Java_com_localoptions_JNIGetUserId_getUser
    (JNIEnv *, jobject);
    #ifdef __cplusplus
    #endif
    #endif
    // Implements method to return a string to Java
    // C++ core header
    #include <iostream.h>
    // header from Java Interface
    #include "JNIGetUserId.h"
    #include "JNIGetUserId2.h"
    // returns a string back to Java for package structure
    JNIEXPORT jstring JNICALL Java_com_services_localoptions_JNIGetUserId_getUser
    ( JNIEnv * env, jobject thisObject )
         // set up constant user id for testing return
         char* userid = "RROWEHLP";
         // return userid to caller
         return env->NewStringUTF( userid );     
    // returns a string back to Java for flat structure
    JNIEXPORT jstring JNICALL Java_JNIGetUserId_getUser
    ( JNIEnv * env1, jobject thisObject1 )
         // set up constant user id for testing return
         char* userid1 = "RROWEHL1";
         // return userid to caller
         return env1->NewStringUTF( userid1 );     
    }

    Ok. A co-worker figured it out for me. The key thing is to do "javah com.services.localoptions.JNIGetUserId". Note the use of "." instead of "\". Running on windows, I was used to doing "\". That was part of the problem. Another key is doing the javah at the top of the package structure. This was mentioned in a post over at IBM.
    We got our JNI stuff working now. thanks, ray.

  • Getting the class name from within the compiled class file

    hey!
    I was wondering (i know its possible) how to read a .class and get the name of the class. ok that made not much sense^^ so, You have a file: c:\f.class but it wont run because the file name has to be the same as the classes name, right? so how can you read the class file i guess in binary mode to receive the correct class name.
    I saw inside my f.class i have "realname.java" so i know now that the name of the class file should be realname.class, i tried ways to extract it from the class file but never had any success.
    i think i need to study english^^
    ps: i need this because i have some class files sent to me and the file names have been changed so they wont work, they only work when i open the class file in notepad and find out what its real name should be and then rename the file.
    Edited by: forgotmydamnpass on May 7, 2009 11:23 AM

    ah looks interesting, problem is i cant use it.. im prone to errors!
    import java.net.URLClassLoader;
    public class NewMain {
         * @param args the command line arguments
        public static void main(String[] args) {
            FileClassLoader loader = new FileClassLoader();
            Class clazz = loader.createclass("c:\\f.class");
            Method method = clazz.getName();
    }apparently "createclass" doesnt exist :/
    FileClassLoader = cannot find symbol
    Method = cannot find symbol

  • I am not able access static methods from startup class

    I have a simple java class which queries the Database and holds some data. I am trying to access a static method of this class from the StartupClass and I am not able to do so. But I am able to access a static variable of the same class.
    Can someone help me here.

    Well, welcome to the world of "hacked" phones. If your purchase was from the US, you obviously purchased an iPhone that is locked to a US carrier. The iPhone must have been jailbroken and unlocked via software to accommodate your foreign SIM card. Now that you have updated the phone, it is locked back to the US carrier. Only the carrier can authorize Apple to unlock the iPhone and none of the US carriers will unlock the iPhones. Best suggestion is to sell the phone and obtain a factory unlocked version directly from the Apple store.
    To answer your other question, there is not a supported method to downgrade iOS.

  • Securing a JSP call from within the OAF

    Dear All
    I am calling a custom JSP file ($OA_HTML/test.jsp) from within the controller class of an OAF page using the pageContext.setForwardURL where the JSP file is registered as an AOL function, so therefore the first parameter of the setForwardURL call is the function name.
    Now the whole reason of wrapping this JSP file around OAF, is to take advantage of OAF’s security framework and Apps Specific Functionality, so that we can perform various security checks and validation before proceeding with the call to the JSP page.
    This is working fine and we are getting the desired result, however, there is nothing stopping someone from directly typing the call to the JSP into the browser and executing the JSP and effectively bypassing the OAF page/controller, e,g:
    http://server.host.domain:port/OA_HTML/test.jsp
    Now the question is, is there any way for us to either
    ·     Prevent a direct execution of the JSP from the URL, by placing some kind of special JSP commands, which intrinsically ties the JSP with the OA controller.
    ·     Inside JSP validate and authenticate a user.
    ·     Any other methodologies that will secure the JSP file.
    Your help and Guidance is appreciated.
    Thanks
    Patrice

    Actually there is AOL security u can use to validate whether the particular jsp is directly invoked or coming from secure session.You can use code like
    WebAppsContext webAppsContext = WebRequestUtil.validateContext(request, response);
    The validateContext method checks whether the session associated with the request and response streams is a valid one - if so it returns a properly validated context. If the session is invalid or expired, this will take care of displaying a login page to the user and the method will return null.
    --Mukul                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • Accessing a private variable from a public method of the same class

    can anyone please tell me how to access a private variable, declared in a private method from a public method of the same class?
    here is the code, i'm trying to get the variable int[][][] grids.
    public static int[][] generateS(boolean[][] constraints)
      private static int[][][] sudokuGrids()
        int[][][] grids; // array of arrays!
        grids = new int[][][]
        {

    Are you sure that you want to have everything static here? You're possibly throwing away all the object-oriented goodness that java has to offer.
    Anyway, it seems to me that you can't get to that variable because it is buried within a method -- think scoping rules. I think that if you want to get at that variable your program design may be under the weather and may benefit from a significant refactoring in an OOP-manner.
    If you need more specific help, then ask away, but give us more information please about what you are trying to accomplish here and how you want to do this. Good luck.
    Pete
    Edited by: petes1234 on Nov 16, 2007 7:51 PM

  • Retrieve data from other context node within the same context

    Hi Experts,
    I want to redefine method BUILD_TABLE for a table context node and I need to access data from another context node within the same context. I have looked through the methods of class CL_BSP_WD_CONTEXT_NODE_TV but could not find a mean of retrieving the other context nodes.
    Any ideas?
    Thanks a lot. Your help is appreciated.
    Cheers,
    Jens

    Hi Jens,
    Check this [wiki|http://wiki.sdn.sap.com/wiki/pages/viewpage.action?pageId=201066680] it should be helpful.
    Regards,
    Shobhit

  • How can I migrate from one user to another within the same computer?

    My main user account in my desktop is becoming buggy after to many migrations from different computers and long time usage. I would like to migrate from one user to another user within the same computer to see if this improves my current problems.
    How can I do it in a reasonably safe and quick way?
    Thank you very much, cheers, Rui
    iMAC, OS 10.6.8... and yes, I love Snow Leopard light and handy... and all my programs work on it...

    Move small groups of files to the /Users/Shared/ folder or another location and see if the problems disappear. Moving everything to a new user account will in all probability transfer the problems.
    (119885)

  • SO idoc from PO idoc within the same client

    Hello SAP Gurus,
    We need help with the following .
    The requirement is we need to create the Sales order from Purchase order using idocs within the same client .
    We created the partner profile of the customer and the vendor .
    Customer ---maintained an inbound parameters with message type ORDERS and process code ORDE
    Vendor -
    maintained outbound parameters with message type ORDERS and idoc type ORDERS05 and process code ME10 .
    Now when we create the PO and check the status in WE02 we get the error status 56 , EDI: Partner profile inbound not available.
    What could be the posible cause of the error .
    Anybody with some suggestions and solutions .
    Thanks
    Honey

    Hi ,
    You should maintain in the inbound parameters  and out bound parameters also
    out bound parametrs
    message typ[e---ORDERS
    receiver port----
    basic type -
    ORDERS05
    tick on transfer idoc immediately
    Inbound parameters
    message type ---ORDERS
    process code --ORDE
    if you have any further clarifications let me know
    Regards
    Damu

  • Is it possible to insert a url link into the itunes description tag. I want the user to be able to access my webpage from within itunes

    Hi,
    Is it possible to insert a url link into the itunes description tag in a feed. I want the user to be able to access my webpage from within itunes
    Thanks

    In the next release, we will be making adding our Measurement Studio components to existing projects much easier, but for now what you would need to do is add the support for Measurement Studio to your MFC project manually as detailed in our Knowledgbase at:
    http://digital.ni.com/public.nsf/3efedde4322fef19862567740067f3cc/0cb6707522e92c958625689e0052bb77?OpenDocument
    Best Regards,
    Chris Matthews
    Measurement Studio Support Manager

  • Simple button action that goes to a page within the same doc

    I can't figure this out. I have a button I want to use that takes a person back to the first, or second page of the same doc. It's a catalog section with a table of contents. I need to make links for the pdf that takes people to certain pages within the same document.
    In the Buttons panel, I see how to make the button, but when I assign an action, the only choice that makes sense is "Go To Destination", but I don't get or see any way to choose "page 2" of the document, or another selection method.
    I did this before a few years ago on hundreds of pages, and when I open those old documents up to copy/paste the same buttons, they don't even appear to have actions on them anymore, as if it never happened.
    So, what's the secret? Certainly there's a way to link to another page in the same ID file, no?

    Finally figured it out. I do NOT use the button panel at all. No buttons needed. Just select the grouped object that I want for my button, and hit the "add hyperlink" button in the Hyperlink panel. Then choose "Page" from the menu that opens up and be on my way. What was throwing me for a bad loop, was that I had copied and pasted the button graphic form another document. Well, since the link made previously was broken now, I had the red flag in the Hyperlinks panel...and thus, the "new hyperlink" button was greyed out, sending me in circles. The minute I deleted the old hyperlink it carried over from the old document, the new hyperlink button worked again and all was well.
    Thanks.

  • How can I POST data within the same page if I have a A HREF -tag as input?

    How can I POST data within the same page if I have a <A HREF>-tag as input? I want the user to click on a line of text (from a database) and then some data should be posted.

    you can use like this or call javascript fuction and submit the form
    <form method=post action="/mypage">
    cnmsdesign.doc     
    </form>

Maybe you are looking for