Why i cann't get the data.

//MyTest.java
import java.sql.*;
public class MyTest
     public static void main( String[] args )
          try
               Class.forName("org.gjt.mm.mysql.Driver");
          //     .newInstance();
               try
                    Connection con = DriverManager.getConnection( "jdbc:mysql://localhost:3306/test" );
                    try
                         Statement statement = con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_READ_ONLY);
                         ResultSet rs = statement.executeQuery("SELECT * FROM mytest");
                         ResultSetMetaData rsmd = rs.getMetaData();
                         String     columnname = rsmd.getColumnName(1);
                         int     columncount = rsmd.getColumnCount();
                         System.out.println(columnname + "     " + columncount);
                         System.out.println(rsmd.getColumnType(1));
                         System.out.println("\n");
                         while ( rs.next() )
                              System.out.println(rs.getString(1));
                         rs.close();
                         statement.close();
                    catch ( SQLException e )
                         System.out.println( "JDBC error: " + e );
                    finally
                         con.close();
               catch( SQLException e )
                    System.out.println( "could not get JDBC connection: " + e );
          catch( Exception e )
               System.out.println( "could not load JDBC driver: " + e );
on mysql, i created the table named mytest
mysql>create table mytest (name varchar(20));
mysql>insert into mytest values("hbsc");
then on the cmd windows
c:>java MyTest;
but i can not the the expected data.
while ( rs.next() )
                              System.out.println(rs.getString(1));
this statement print nothing, if debug infomation inserted into the while loop,
we can get the debug info,not the data. it seems nothing is fetched from the table. and when i change getString(1) to getString("name");
C:\>java MyTest
1
12
JDBC error: java.sql.SQLException: Column 'name' not found.
what to do ?

I've tried your program with a couple of small changes as shown below:
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver").newInstance();  // use sun's driver instead
try {
   Connection con = DriverManager.getConnection( "jdbc:odbc:mysqldemo" );   // no need for host stuffand it works fine!
;o)
V.V.
PS: this is what I have on the system with Windows XP-Pro:
Product : MySQL, Version : 4.0.12-max-nt
Driver : JDBC-ODBC Bridge (myodbc3.dll), Version : 2.0001 (03.51.06)

Similar Messages

  • In the iSO 7 in the map app: Why we cann't get the direction information of the riad in the meddileast region

    I cann't get the direction information of the roads in my country Saudi Arabia

    Turn bu turn navigation in Saudi Arabia is not supported.
    http://www.apple.com/ios/feature-availability/

  • Why i cann't get the executed step index of main segment of a sequence?

    Hi, Everyone!
    Could someone help me ,Pls?
    Query:
            How can i get the executed step index of main segment of a executed sequence?
    Aim:
           I want to let Teststand reveal the executed step index no matter when it running in main segment, setup segment or cleanup segment when i terminate executing sequence.
    My action:
          I add a Statement step in SequenceFilePostStep , the content is FileGlobals.GetArrayOffset1= RunState.Sequence.Main.GetArrayOffset("Pass/Fail Test1",0,"0").
          but it cann't work, and it is error.

    The backslashs are escape characters which tell the expression to interpret the " " as actual quotes. Since the expression Doug posted had other quote marks in it here: ("", 0, "[\"Pass/Fail Test1\"]")  we have to escape the inner quotation marks so that the expression will be interpreted correctly. The backslash does this.
    Daniel E.
    TestStand Product Support Engineer
    National Instruments

  • Why do we get the data from a view to a report.

    hi
    why do we get the data from a view to a report. is it possible to get the data from a view in all the cases?

    hi Jyotssna,
      Suppose you are planning to get the data from multiple tables then you got to specify seveal condtions and make use of joins which results in poor performance in fetching the data . In order to improve the performance we make use of views where the conditions of different tables are defined and the data is fetched accordingly.
    Regards,
    Santosh

  • My iPhone says "o death" where the date should be on the lock screen, why is it doing this and how do I get the date back?

    My iPhone says "o death" where the date should be on the lock screen, why is it doing this and how do I get the date back?

    I tried powering off and on and it went away, but I can't tell if it's been broken into since everything works fine (I'm using it now) is there a test to see if it's been broken into?
    Thanks for all your replies!

  • When I look up the creation date for files on my Macbook I get the date and month in brackets, but not the year.  Why is this and how can I look up the year?

    When I look up the creation date for files on my Macbook (using "get info", or the information window in Iphoto) I get the date and month in brackets, but not the year.  Why is this and how can I look up the year? 

    Does the Date Modified column in a window set to List view show the date correctly, or does it also display it incorrectly?
    To add additional columns to a Finder (folder) window, with that window open and active open the View Options for it. You can do that by pressing Command-J or by selecting View Options from the View menu in the main menubar.

  • Refernce Nav igational Attribute is not getting the data in Infoprovider

    Hi,
    I am facing the issue with Reference Characteristic which is  a navigational attribute for which data  is not getting populated in the cube.Please find the below scenario.
    We have three characteristics 0RECV_WBS_E , 0WBS_ELEMT, ZPSBUSA .Char 0RECV_WBS_E is reference of 0WBS_ELEMT.
    0RECV_WBS_E__ZPSBUSA,0WBS_ELEMT__ZPSBUSA are the Navigational attributes of ZPSBUSA, these two are maintained as Navigational attributes in the cube and at info object level. The Nav Attribute  0RECV_WBS_E__ZPSBUSA is not getting the data in infocube where as 0WBS_ELEMT__ZPSBUSA is getting the data .The data is available for the two Nav attributes in the info object ZPSBUSA .Can you please suggest why this reference Nav attribute  0RECV_WBS_E__ZPSBUSA is not getting data in the infocube.
    Thanks,
    SUbhash

    Hi,
    I am facing the issue with Reference Characteristic which is a navigational attribute for which data is not getting populated in the cube.Please find the below scenario.
    We have three characteristics 0RECV_WBS_E , 0WBS_ELEMT, ZPSBUSA .Char 0RECV_WBS_E is reference of 0WBS_ELEMT.
    0RECV_WBS_E__ZPSBUSA,0WBS_ELEMT__ZPSBUSA are the Navigational attributes of 0WBS_ELEMT, these two are maintained as Navigational attributes in the cube and at info object level. The Nav Attribute 0RECV_WBS_E__ZPSBUSA is not getting the data in infocube where as 0WBS_ELEMT__ZPSBUSA is getting the data .The data is available for the two Nav attributes in the info object 0WBS_ELEMT .Can you please suggest why this reference Nav attribute 0RECV_WBS_E__ZPSBUSA is not getting data in the infocube.
    Thanks,
    SUbhash
    Edited by: MarkSubhash on Dec 9, 2011 11:11 AM

  • Iam not getting the data on screen after using the user exit zxpadu01

    Dear Freinds
                As per my requirement when the user enters value Ansal  it should get defaulted to Amount field (bet01 ) based on the wage type
    i have written calculation ( q0008-bet01 = ansal/100) before it getting defaulted to bet01, i found that value is not getting default  on the screen for bet01 once i enter value for Ansal , please any body correct my code
    in   ZXPADU02 i have written the code as  below :
    data : wa_p0008 like p0008,
            i0008 like p0008,
           l_v_ANSAL type ANSAL_15,
           l_v_amount type PAD_AMT7S.
    CASE innnn-infty.
    when '0008'.
    CALL METHOD cl_hr_pnnnn_type_cast=>prelp_to_pnnnn
    EXPORTING
    prelp = innnn
    IMPORTING
    pnnnn = wa_p0008.   -- HERE I GOT ALL THE DATA EXCEPT BET01
    if wa_p0008-lga01 = 'MFPY'.
    l_v_ansal =  wa_p0008-ansal.
    l_v_amount = l_v_ansal / 100.
    move l_v_amount to wa_p0008-bet01.
    CALL METHOD cl_hr_pnnnn_type_cast=>pnnnn_to_prelp
    EXPORTING
    pnnnn = wa_p0008  --- HERE I CAN SEE EVEN THE BET01 IS FILLED
    IMPORTING
    prelp = innnn.         --- HERE I CAN SEE LGART BUT NOT AMOUNT VALUE
    endif.
    when others.
    endcase.
    IN ZXPADU01 I HAVE WRITTEN AS BELOW:
    data : wa_p0008 like p0008,
            i0008 like p0008,
           l_v_ANSAL type ANSAL_15,
           l_v_amount type PAD_AMT7S.
    CASE innnn-infty.
    when '0008'.
    MOVE-CORRESPONDING  innnn to wa_p0008.
    CALL METHOD cl_hr_pnnnn_type_cast=>prelp_to_pnnnn
    EXPORTING
    prelp = innnn
    IMPORTING
    pnnnn = wa_p0008.
    if wa_p0008-lga01 = 'MFPY'.
    l_v_ansal =  wa_p0008-ansal.
    l_v_amount = l_v_ansal / 100.
    move l_v_amount to wa_p0008-bet01.
    CALL METHOD cl_hr_pnnnn_type_cast=>pnnnn_to_prelp
    EXPORTING
    pnnnn = wa_p0008   --- I CAN SEE ONLY WHEN I COME AGAIN
    IMPORTING
    prelp = innnn.
    endif.
    when others.
    endcase.
    Now my problem is as follows :
                   i have entered the value for Ansal (ex: p0008-Ansal = 1000) ..........and i say enter then i should found the calculated value for the ansal through my coding
    and it should  display in bet01 as 10 ( q0008-bet01 =  p0008-ansal /100)
    but i dont find the value 10 being displayed for the field bet01 on the screen  when
    user enters Ansal  as 1000 .........even then i have saved it to test the scenario......
    now i came in displayed mode (pa20 ) for the infotype 008 for the same personnel no for the same  dates .....where i created the record........i found that the value
    bet01 is there i.e i can see  the value bet01 as 10 ( my requiremnt here matching)
    but when the user say enter during the time of creation of the record the value
    bet01 is not getting defaulted with 10 .........why iam not able to understand
    PLEASE ANY BODY HELP ME IN THIS REGARD 
    regards
    shanti.

    Hi Pranesh,
                   i have used the logic which you hav given as below
    in ZXPADU02
      FIELD-SYMBOLS <fs>  TYPE ANY.
    ASSIGN ('(MP000800)Q0008-betrg') TO <fs>.
    if <fs> is assigned.
    <fs> = l_v_amount .  ---  amount as (ansal /100 i.e 1000/100 = 10) 10
    endif.
    still iam not getting the data for the field bet01
    this is the coding i am using
    data : wa_p0008 like p0008,
            i0008 like p0008,
           l_v_ANSAL type ANSAL_15,
           l_v_amount type PAD_AMT7S.
      FIELD-SYMBOLS <fs>  TYPE ANY.
    CASE innnn-infty.
    when '0008'.
    MOVE-CORRESPONDING  innnn to wa_p0008.
    CALL METHOD cl_hr_pnnnn_type_cast=>prelp_to_pnnnn
    EXPORTING
    prelp = innnn
    IMPORTING
    pnnnn = wa_p0008.
    if wa_p0008-lga01 = 'MFPY'.
    l_v_ansal =  wa_p0008-ansal.
    l_v_amount = l_v_ansal / 100.
    move l_v_amount to wa_p0008-bet01.
    ASSIGN ('(MP000800)Q0008-betrg') TO <fs>.
    if <fs> is assigned.
    <fs> = l_v_amount .
    endif.
    CALL METHOD cl_hr_pnnnn_type_cast=>pnnnn_to_prelp
    EXPORTING
    pnnnn = wa_p0008
    IMPORTING
    prelp = innnn.
    endif.
    when others.
    endcase.
    please help me as iam still not getting (value in bet 01) when i press enter once i enter value in ansal feild.
    regards
    shanti.

  • Get the date and time from iframe.

    Hi,
    Am using jdeveloper 11.1.1.6.0., I have used the following iframe source which gets the date and time.
    <af:form>
    <iframe src="http://free.timeanddate.com/clock/i3xb4nm0/n1722/tt0/tw0/ts1" frameborder="0" width="244" height="19">
          </iframe>
    </af:form>
    I need to get the date and time separately to perform some validation. How can i  get it.
    regards,
    Prasad K T,
    9840021070

    Prasad,
    I don't understand your use case. The url you use is a json web service which returns it's result as either xml or json payload. Why do you pretty print this as a web page and try to get to the result this way?
    Why don't you get the result directly using the json result or (AFAIK) the java script api which the service also provides.  Check the documentation of the service.
    From your description I understand that the user enters a time. You need to know if the time is before or after 2:30pm and have to set a 'shift' to A or B.
    Where do I need a timeservice in this validation?
    From what I see your approach won't work. As I still don't understand the use case I don't know how to help.
    Timo

  • Native query. How to get the data...

    Hello everyone!
    I'm struggling to figure out how to extract data from particular columns from DB. Here is what I have...
    A table PersData with columns A, B, C, D and so forth. Also there is an entity represents this table called PersonalData.
    I need to get the data from A and C columns, but I still haven't found a solution how to do this. I know how to exctract an entire row from the PersData table by writing the following code...
    Query query = entityManager.createNativeQuery("SELECT * FROM 'PersData` ", PersonalData.class);
    List<PersonalData> qresult = query.getResultList();
    for(PersonalData item: qresult){
          System.out.println(item.getA());
          ........ But it's inefficient to get values of other columns at the same time.
    I guess that my query should be written smth like this...
    Query query = entityManager.createNativeQuery("SELECT A, C FROM `PersData` ");
    List<PersonalData> qresult = query.getResultList();
    for(PersonalData item: qresult){
          System.out.println(item.getA());
          .....But I got an error java.lang.ClassCastException when I do this for (PersonalData item: qresult). Actually, I understand why it's like this.
    Does anybody know how to get values just from two columns and then use them?

    Oops, my bad. it was about 2 paragraphs further
    down...
    "autoGeneratedKeys - a constant indicating whether
    auto-generated keys should be made available for
    retrieval using the method getGeneratedKeys;"Down in what?
    The following is the docs for the method you posted taken from here - http://java.sun.com/j2se/1.4.2/docs/api/java/sql/Statement.html#executeUpdate(java.lang.String, int).
    executeUpdate
    public int executeUpdate(String sql,
    int autoGeneratedKeys)
    throws SQLException
    Executes the given SQL statement and signals the driver with the given flag about whether the auto-generated keys produced by this Statement object should be made available for retrieval.
    Parameters:
    sql - must be an SQL INSERT, UPDATE or DELETE statement or an SQL statement that returns nothing
    autoGeneratedKeys - a flag indicating whether auto-generated keys should be made available for retrieval; one of the following constants: Statement.RETURN_GENERATED_KEYS Statement.NO_GENERATED_KEYS
    Returns:
    either the row count for INSERT, UPDATE or DELETE statements, or 0 for SQL statements that return nothing
    Throws:
    SQLException - if a database access error occurs, the given SQL statement returns a ResultSet object, or the given constant is not one of those allowed
    Since:
    1.4
    I don't see the text you posted in there.
    At the very least there is at least a suggestion that an exception will be or could be thrown because the only way some databases can return an autogenerated key is via a result set.

  • How do i get the date when enter a week number

    Hi, can anyone tell me how do i get the date when enter a week number??
    let say, i enter week number 4 and year 2008
    result=26-01-2008
    thanks..

    import java.util.Calendar;
    public class testCalendar {
         public static void main(String args[]){              
              int year=2008;
              int week =5;
              Calendar now=Calendar.getInstance();
              now.set(Calendar.YEAR,year);
    now.set(Calendar.WEEK_OF_YEAR,week);
              System.out.println(now.getTime());          
    hai, anyone know why i can't get the result:27-01-2008
    i always get two day later. That is 29-01-2008
    no wonder how i change the week number and year.
    for example: week=7, year=2007
    expected result:11-02-2007
    but the result is 13-02-2007
    thanks..
    Edited by: Angel_Wei on Sep 1, 2008 11:58 PM

  • Why we need to Stage the Data in DSO/ODS before InfoCube?

    Hi
    I have one question related to BW modeling.
    1.   Why we need to stage the data in DSO/ODS before loading into InfoCube?
    Thanks
    Raj

    There are multiple reasons:
    one, some extractors specially finance send you data after image, in that case you can only do overwrite in dso not in cube.. cube is always addition. Second, you keep detail data in DSO and more summarized data in the cube and write a jump query if you need detail data. This is more for performance reason. Third, in some cases you can generate delta within dso, so dso is very important here. Forth, in dso you always store data as it comes from the source, you do your data massaging in the next layer. If you get some issues in the data, you don't need to go and get the data from the source, but from your dso. I know long time ago, space is issue and there was no need to store data in multiple layers, but now space is not issue so the benefite we are getting by storing the data in dso outweight the space concern.
    thanks.
    Wond

  • I want to talk to someone about why I can't get a data add on.

    I want to talk to someone about why I can't get a data add on. 150 useless none of the options get me to a real pErson. Tried to text that I wanted a data addin it keeps saying it is not available on this account. Been driven potty

    007 wrote:
    TextDP1 to 150 which is a£1100mb dataaddon for 7 days
    : DP1 is not an add-on; it is a Data Pack & it wont kick in till current pack expired.
    What  needs to do text 100 MB WEEK or 500 MB (for the month) to 150 to get data add-ons now as he wants.

  • Why can't anybody get the photos I send them from my Iphone 4s? I've sent it to blackberries, iPhone 3G, and other phones - nothing has been able to get them!

    Why can't anybody get the photos I send them from my Iphone 4s? I've sent it to blackberries, iPhone 3G, and other phones - nothing has been able to get them!

    Do you get a send error message or a red "!" when you send?  Do you have a data plan on your account?  Check that your carrier has you provisioned for MMS.

  • Why didn't I get the iOS 7.0

    Why didn't I get the iOS 7.0 update?

    Because it's not publicly available at this time. Apple may announce its release date at tomorrow's event.
    (88729)

Maybe you are looking for

  • Cannot send mail after upgrading to Lion

    Can anyone help. I upgraded to OS X Lion, and since then I cannot send mail from any of my accounts. Nothing wrong with them. I can access, receive and send with othe Mail programs, as well as from my iPhone and iPad. I have deleted, and reconfigured

  • Acrobat Pro 9.0 and 9.1 crash using Portable Home Directory

    Installed 9.0 as part of CS4 Design Suite, and updated to 9.1. Runs OK for user on local machine but crashes when used by a portable home directory user on same machine, accessing user on OSX Server on local network. Safari also crashes when accessin

  • Deadlock alert

    read in the manual that deadlock (ora-00060) is treated separately as are also the block corrupted and archive hung alerts. But can not find anything to manage the deadlock message. These messages appear in the alert log file but EM 10g does not capt

  • SD migration issue

    We are on the process of migration and we are checking "Customzing Cross-system Viewer (SCU0)" in order to compare 2 servers (server 20 & 30). This tcode will list down all the configuration and compares the 2 servers. Looking at the image below (the

  • Finding a file in the current executable jar file.

    Hi all, I am writing a little command line type application and I thought it would be neat to embed it's 'help file' into it's executable JAR file. Please can someone show me how to code my application to extract a file from the JAR file from which t