Java and sql question

is ther a way to index in an atumatic way the rows of a database table?
for example if i delete the row numer 4, there will be no more index 4. So i need that when i delete a row the hole table indexes again the rows in order to not lose the index number of the row it has benn deleted.
am i clear enough, excuse my englis thanks

Perhaps you should say what you are trying to do and why to make it clearer.
Recalculating an index for every record in the database every time sounds quite hard on the processor.
My database automatically gives a unique number called an oid to every record, which I often find useful.

Similar Messages

  • Inconsistent java and sql object types

    Hi,
    I have run into error "Inconsistent java and sql object types"
    while mapping a java class to a sql object type. The java class
    is just a duplicate of sql data structure and I pretty much
    follow the JDBC Developer's GUide's examples (20-43 to 20-45)
    to create the mapping java class.
    Any one runs into simliar problem or any clues?
    Thanks,
    Ed
    Exception in thread "main" java.sql.SQLException: Inconsistent java and sql object types: InstantiationException:
    at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:168)
    at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:210)
    at oracle.sql.STRUCT.toClass(STRUCT.java:433)
    at oracle.sql.STRUCT.toJdbc(STRUCT.java:366)
    at oracle.jdbc.oracore.OracleTypeUPT.unpickle80rec
    (OracleTypeUPT.java:236)
    at
    oracle.jdbc.oracore.OracleTypeCOLLECTION.unpickle80rec_elems
    (OracleTypeCOLLECTION.java:553)
    at oracle.jdbc.oracore.OracleTypeCOLLECTION.unpickle80rec
    (OracleTypeCOLLECTION.java:383)
    at oracle.jdbc.oracore.OracleTypeCOLLECTION.unpickle80
    (OracleTypeCOLLECTION.java:329)
    at oracle.jdbc.oracore.OracleTypeCOLLECTION.unlinearize
    (OracleTypeCOLLECTION.java:218)
    at oracle.sql.ArrayDescriptor.toJavaArray
    (ArrayDescriptor.java:501)
    at oracle.sql.ARRAY.getArray(ARRAY.java:197)

    The safest way would be to use JPublisher to generate the type classes. In your application, you can just use the generated code to manipulate the object.

  • The java and sql object type  was not matched

    My table(Oracle10.2) has a varying arrays column. For mapping to java classes, I use JDeveloper(10.1.3.1.0) to generate java classes. Then I try to insert a record into this varrying arrays column with java. While it always complaints java.sql.SQLException.the java and sql object type was not matched. I can not find the reason.
    My java code:
                   StructDescriptor structdesc = StructDescriptor.createDescriptor(
                             "VARRAY_SEQ", con);
                   int nid=20;
                   int pid=546;
                   BigDecimal mynid=new BigDecimal(nid);
                   mynid=mynid.setScale(0, BigDecimal.ROUND_HALF_UP);
                   BigDecimal mypid=new BigDecimal(pid);
                   mypid=mypid.setScale(0, BigDecimal.ROUND_HALF_UP);
                   Object[] attributes = { "ASDF", mynid, "Developer", mypid,
                             "rwretw" };
                   STRUCT Rel = new STRUCT(structdesc, con, attributes);
                   stmt.setObject(8, Rel);
                   stmt.execute();
                   stmt.close();
    And the STRUCT is
    public RelSeq(String nucl, java.math.BigDecimal neId, String nuor, java.math.BigDecimal pId, String phor) throws SQLException
    { _init_struct(true);
    setNucl(nucl);
    setNeId(neId);
    setNuor(nuor);
    setPId(pId);
    setPhor(phor);
    }

    My table(Oracle10.2) has a varying arrays column. For mapping to java classes, I use JDeveloper(10.1.3.1.0) to generate java classes. Then I try to insert a record into this varrying arrays column with java. While it always complaints java.sql.SQLException.the java and sql object type was not matched. I can not find the reason.
    My java code:
                   StructDescriptor structdesc = StructDescriptor.createDescriptor(
                             "VARRAY_SEQ", con);
                   int nid=20;
                   int pid=546;
                   BigDecimal mynid=new BigDecimal(nid);
                   mynid=mynid.setScale(0, BigDecimal.ROUND_HALF_UP);
                   BigDecimal mypid=new BigDecimal(pid);
                   mypid=mypid.setScale(0, BigDecimal.ROUND_HALF_UP);
                   Object[] attributes = { "ASDF", mynid, "Developer", mypid,
                             "rwretw" };
                   STRUCT Rel = new STRUCT(structdesc, con, attributes);
                   stmt.setObject(8, Rel);
                   stmt.execute();
                   stmt.close();
    And the STRUCT is
    public RelSeq(String nucl, java.math.BigDecimal neId, String nuor, java.math.BigDecimal pId, String phor) throws SQLException
    { _init_struct(true);
    setNucl(nucl);
    setNeId(neId);
    setNuor(nuor);
    setPId(pId);
    setPhor(phor);
    }

  • ERROR: Inconsistent java and sql object types

    I am getting a nested object table in the form of an oracle.sql.ARRAY. I then call getResultSet() on this array and try to cast each object into a Java implementation of the SQLData interface (also defined in the connections type map).
    This approach works for one nested object table but not for another. I get the error message:
    "Inconsistent java and sql object types"
    Does this mean that my Java to Oracle type mappings are wrong? Any help would be appreciated.
    Regards
    Steve

    i had a similar situation. found out it was occuring because the oracle type had not been granted to the appropriate user.
    todd kegley

  • Java and SQL #2

    Hi all,
    Please could someone give a sample code of how to connect java to SQL.
    Thanks in advance for your help.
    Best regards.
    Saadi Monla

    Read the Java Tutorial on this site. Look up JDBC.

  • Java and Networks - questions

    Hi,
    I have this idea in my head, and i wanna get it out..
    Okie the plan is that I want to create something like a macro program. The special thing is that I want to create a server and 2 clients. The thing I want is that whenever I hit a special key from Client1, that key is going to be sent to the server,then the server is going to modify it, and then send to the Client2. And then the Client2 will invoke the key just like a macro program.
    Okie the networking part, I kindda have an idea what how to do it. However since it is more like a macro program, I want it (client/server) to run simutaniously with other programs I am running.
    Ex:
    Let's say I am playing a game, I hit number 1 to signal the game that I want my unit to attack something. Meanwhile the Client gotta capture the key 1 that I just hit and send it to the server and then the client2, and then perform an action of pressing a key that a server sends to.
    Could anyone have an idea of how to do the capture keys and invoke keys as I mentioned above?
    Thank you
    please email me at [email protected] if you could help me out

    JNI (Java Native Interface) is the interface between Java and C (usually native functions in C). In C you can do a lot more low-level stuff than in Java, particularly interacting with the OS at a system level. This is the native part.
    Ie, the system knows about all key events. It then sends them to the OS, that only directs them to the program with focus. (Might be java, might not. But no program can get keyevents intended for another program).
    Using JNI, you could intercept the keyevents betweent the system and the os, and do what you want with them.
    But, I don't know JNI, and I don't know much about it. This is mainly guesswork. It's along the right track, but the system/os stuff might not be 100% correct.
    The other thing is, once you start writing code that interacts directly with the system, it loses all cross-platform compatibility. IE, if you write something that interacts with windows, it obviously won't work on Linux.
    Cheers,
    Radish21

  • Java and sql:

    Hello,
    I wrote a java program to connect with ms access, and wished to ask if there was a sql command to delete all records from a table?
    Thanks

    And just be sure, would I be correct the sql AND
    cannot be used with delete?Sure you can use AND with DELETE:DELETE FROM yourTableHere WHERE yourConditionsHere AND moreConditionsHereBut you can't sayDELETE FROM yourTable AND FROM yourOtherTableif that's what the question meant.

  • Problems with java and SQL

    Hi all. Not sure if I should ask this here or in an SQL forum. I�m trying to manipulate an access database through java via the JDBC-ODBC bridge driver. The program compiles ok but when I try to execute it I get an error. According to the error there is a syntax problem in my SQL create table statement but it doesn�t tell what the problem is and I�ve looked over the create statement and can�t find anything wrong with it. There is, however, an error code from the driver but I have no way of referencing it. Anyone here know why otherwise normal SQL code would cause a syntax error with java or how I can track the error to get a hint at what�s going wrong? Here is the code and the error:
    // java program to create an access database through JDBC
    import java.sql.*;
    public class videodb {
    public static void main(String args[]) {
         // attempt tp load DB driver
         try {
         // load the jdbc-odbc driver
         Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
         catch (ClassNotFoundException cnfe) // driver not found
         System.err.println("Unable to load database driver");
         System.err.println("Details : " + cnfe);
         System.exit(0);
         try {
         // Create a connection to the data source
              Connection con = DriverManager.getConnection ("jdbc:odbc:vdds","","");
              // Create a statement to execute SQL commands     
              Statement stmt = con.createStatement();
              // create a table for DVD's
              stmt.executeUpdate ("create table DVD (id number(5), name char(30));");
              // insert a record into the DVD table
              //stmt.executeUpdate ("insert into DVD values (0001, 'StarGate');");
              // Close the connection
         con.close();
         catch (SQLException sqle) {
    System.out.println("Problem with SQL: " + sqle);
    System.out.println("Driver Error Number" + sqle.getErrorCode());     
    Error:
    Problem with SQL: java.sql.SQLException: [Microsoft][ODBC Microsoft Access Driver] Syntax error in CREATE TABLE statement.
    Driver Error Number-3551

    Here's what I got. I don't see anything that helps but I'm kinda new to using SQL and java together.
    D:\javatemp\viddb>java videodb
    Problem with SQL java.sql.SQLException: [Microsoft][ODBC Microsoft Access Driver
    ] Syntax error in CREATE TABLE statement.
    Driver Error Number-3551
    java.sql.SQLException: [Microsoft][ODBC Microsoft Access Driver] Syntax error in
    CREATE TABLE statement.
    at sun.jdbc.odbc.JdbcOdbc.createSQLException(Unknown Source)
    at sun.jdbc.odbc.JdbcOdbc.standardError(Unknown Source)
    at sun.jdbc.odbc.JdbcOdbc.SQLExecDirect(Unknown Source)
    at sun.jdbc.odbc.JdbcOdbcStatement.execute(Unknown Source)
    at sun.jdbc.odbc.JdbcOdbcStatement.executeUpdate(Unknown Source)
    at videodb.main(videodb.java:31)
    D:\javatemp\viddb>

  • How to Change the default format for differnt language both in java and SQL

    Hello,
    I am using SQL Anywhere in my application.And in my java client application user can log in with their preferred language like English,French,German,Chinese,etc....When even the user log in to the application the data from the database will be displayed with respective to the language.But when i tried to see the dates in Interactive SQL all the dates r in the format of '2008-12-5 16:44:10:673' but say for example for Chinese it will be displayed as '08-12-5 16.44.10' and for some other language it will come in some other format(which is standard format for those language).
    Mean while i am using java client.When ever i am displaying a date it will be with respective to the language using Locale and date format classes.When i am displaying the date for Chinese in GUI it will show the date as '08-12-5 下午4:44'. In summary
    1. For Chinese,the default date pattern from SQL Anywhere date base is '08-12-5 16.44.10'
    2. For the same language date using java code is displaying as '08-12-5 下午4:44'. and i am getting the time format pattern as 'ah:mm'.I tried to change the display format in regional settings but no change in display.
    Is there any way to make both the time format as same?
    Please help me to solve this issue!!!
    Thanks in Advance!
    Arun

    pon_arun wrote:
    Hello masijade,
    I did as u said but still the date display is not the same......And I'm telling you that it doesn't matter. What "format" the DB likes to display a Date in when it displays it, is completely irrelevant to how you display it in your GUI.
    A Date does not have a format. A String representation of a Date does.
    As long as you use getDate from ResultSet and setDate from PreparedStatement you do not have to worry about this. Those methods will handle dates to and from the DB themselves. You can then use SimpleDateFormat to display the Date anyway you want to.
    Just because you show the Date one way, and the DB shows it another, does not mean that it is not the same date. Don't get hung up on how the String representation of the Date looks.
    Edit: If you simply want to be able to do "Human Comparisons" then look at the SQL TO_CHAR function (for Oracle, for other DBs the function name may vary). And for Java, read the API docs for SimpleDateFormat (as already intimated above).

  • Java and SQL? Where do I begin?

    I am wanting to educate myself on how to use SQL and Java together. I am looking for some decent tutorials that can expedite this task.
    Know of any resources you could share with me?

    You can also try Sun's JDBC tutorial:
    http://java.sun.com/docs/books/tutorial/jdbc/index.html

  • Paging space and SQL  question

    Can someone tell me why a SQL statement , ie.
    select count(*) from some_table;
    Would take up excessive paging space on my server.

    thank you for your help rago, but I am afraid I am
    more confused from your response.
    is important investigate on the minfree/maxfree,
    is the amount of the RAM dedicated at procs/file ,on unix
    What do you mean here?contact your sysadmin,
    this parameter, OS, indicate the amount of the RAM
    to dedicate at proc and/or at files !
    similar parameter
    pghead
    minperc/maxperc ...
    investigate on the
    pagefault/syscall/swap area/pagin/pagout/. . .
    top
    topas
    admintool, ?,
    vmtune
    >
    And are you suggesting I increase my Shared pool to
    375MB ?this the limit suggest to increase the sga on your system,
    if the system have 1500 MB of RAM ,
    then max amount suggest for allocate the SGA is 75%,
    1500 * 0.75 = 1125 for the 3 instance, on the machine !
    1125 / 3 = 375 MB of RAM suggest to allocate.
    I feel like , and my database is showing symptons of
    the shared pool using paging space - so indicating
    the shared pool is more than the available RAM.the question is:
    1- if you have sufficient SGA, 1125 MB
    but the OS dedicate to processes only
    its 20% of the RAM -> 300 MB of RAM
    the remaining is swap, that increase dayly !
    2- if you have insufficient sga, the sga
    swap continuously , with high page fault.
    rago pasquale

  • Java and sql CONCAT_WS

    I am using a JTable to display tables from a mysql server
    and this is what happens
    Everything works fine except when in my views i have a collumn which is made fom a concatenation
    Here is an example: CONCAT_WS(':',SW.NAME,B.NAME,SP.PORT)
    this in my table is display as [B@2cdf...
    while CONCAT_WS(':',SW.NAME,B.NAME)
    is display as aswitch:aname which is exactly what i want
    Can somebody tell me why java or jtable do not like more than 2 attribute for the concat

    this in my table is display as [[email protected] you are getting there is an array of bytes, and that's the default way of formatting an array of bytes as a String. But it's not a very useful way. You need to find out what's in that array and then decide how to make it into a String for your JTable renderer. Possiblynew String(yourData)would work, and possibly not.
    Or perhaps you don't understand how that CONCAT_WS function works. (I don't understand it, let me mention that.) Based on the column names you have there my guess is that you are trying to lump together both text and numeric data, and it doesn't work the way you assumed it would. Personally I would do formatting in Java instead of using proprietary database functions.

  • Java and encryption - question please...

    Hi all,
    Does Java provides libraries for encryptions eg DES. or i need to find Dll or alternatively write the whole crap?
    any hint, online tips , example will be appreciated.
    best regards
    rahman

    Thanks for quick replies of you guys!!
    I really really appreciated.
    Mine is jdk 1.4 which means i already have the encryption stuff.
    Is there any example available to show usage of one of these encryptions eg DES at all.
    will be really appreciated.
    regards
    rahman

  • How to connect Java and Microsoft SQL Server 2000

    hi,
    could anyone please teach me how to connect Java and SQL Sever 2000?? if possible could you guys provide me with an example??? i could hardly find any relevant resources about it...
    Thanks ~!

    thanks for the information...
    by the way hv any working module on it?? i'm new to
    both Java and Microsoft SQL Server... Thanks againFirst things first... you should read this:
    http://java.sun.com/docs/books/tutorial/jdbc/
    This is microsofts official JDBC Driver: http://www.microsoft.com/sql/downloads/jdbcregister.asp
    Install it and the documentation has some usage examples

  • Help in Access and SQL

    I know i am posting a MS Access and SQL Question in this forum but if someone can help me i really need it urgetn and i though i will find people here who know both of them.
    I need to call a SQL procedure from the Access.
    I want to use a button and as soon as press it i need the
    procedure to run from the sql.My application already
    loads and connects me to the SQL database as it is
    accessing certain tables and views from the database
    which are shared and the application is shared too.
    I need to know the exact syntax please if anyone can help
    me .
    I know the name of the procedure in SQL and it is save
    there. say its name is procA and i want this one to be
    called.
    Thanks a lot

    In order to call a stored proc on another database from MS Access, you need to use a "pass-through" query. Essentially, Access will just pass the sql string to the other database without attempting to do anything with it. Depending on what exactly your proc. does, you may need to set different parameters ofthe query object.
    Serach the Access help for pass-through query for more details.
    TTFN
    John

Maybe you are looking for