Query Command in JDBC

hi, everybody
now, for try to finish a project about house query, u know, there have many fields(information) about the house, as well as the hourse owner's information.
suppose u want to know the price, address, facilities and the owner's information, u must use the select command to join two or three different tables, and possibly there have more than 256 sentences about the select command, wow, too much?
so, how can i make anothre ways to finish this problem.
please help me!

One way to control a database when the are a 'lot' of attributes is to create a named attribute table. So instead of this
  table X - fields: name, color, width, height, finish, texture, cost
  data X
         bear, brown,       14, 14, shiny, fuzzy, $14
         top,  red and blue, 3,  3, shiny, hard,  $1
.one uses this
  table X - fields: name, id, cost
  table Attr - fields: X_id, name, value
  Data X
         bear, 1, $14
         top,  2, $1
  Data Y
         1,  color, brown
         1,  width, 14
         1,  height, 14
         1,  finish, shiny
         1,  texture, fuzzy
         2,  color, red and blue
         2,  width, 3
         2,  height, 3
         2,  finish, shiny
         2,  texture, hard
     The trade off is ease of use in programming vs more complex logic and possibly more storage space (noting that name in Y could be a number saves on space.)
This might actually result in saving space if the attribute values are sparse - not all of them have values.
This can slow down searches and make queries slower. But that greatly depends on the query. There are cases where this can make it substantially faster. That depends on the nature of the data and the needed queries.
An alternative to this is to make a table for each attribute. Once again there are trade offs there. And it probably isn't applicable for 'attributes for a house'.
Notice in the above that cost is not part of the attribute table. This is a design decision that once again is driven by the needed queries. Presumably cost is an important query item, it will always exist and will always be returned for any query. So it can remain in the main table.
An additional table can be used - an attribute name table. Doing this, and writing code which supports the use of that makes it extremely easy to add new attributes.

Similar Messages

  • Operating System Command in JDBC Sender

    Hello everybody,
    I'm trying to find some syntax to execute an operating system command on Windows Server 2003, but the commands don't seem to work I'm actually trying to generate a directory, now the problem is that I can't find syntax examples on how to do this I tried something like MKDIR TEST, now is the syntax of the command lines as you write them in Command Prompt, or maybe there is my error, thanks in advance.
    Regards,

    Confirmed.
    JDBC sender also support OS command.
    Refer to note 841704 if you face any issue while executing OS command in JDBC adapter.
    Note: OS Command execute when processing in database executed successfully. It is even independent on OS command Errors.
    Thanks
    Farooq
    Edited by: Farooq Farooqui on Jan 16, 2009 11:36 AM

  • Problem with delete command through JDBC

    hi all,
    I have the following code in a Java program
    try
    DriverManager.registerDriver
    (new oracle.jdbc.driver.OracleDriver());
    conn = DriverManager.getConnection(
    "jdbc:oracle:thin:@localhost:1521:orcl", "airport", "airport");
    catch (SQLException ex)
    ex.printStackTrace();
    Every statement works fine except the delete command. When i try to execute this statement:
    stmt = conn.createStatement();
    stmt.executeUpdate("DELETE FROM distances");
    the program stalls. The table "distances" is owned by the user airport and this sql command works fine when I execute it in SQL+. The problem occurs when I try to execute a delete command through JDBC.
    Can anyone help me?
    Thanks...

    It seems that the problem ocuurs only when there are pending transactions.Correct. There are uncommitted INSERT/UPDATE/DELETEs on the table. Readers never block writers, thus having opened SELECT cursors on the table is not a problem. You writer process must be blocked by another writer process. (assuming of course no JDBC thin driver error - of which I've heard rumours there are or were quite a few - not using thin JDBC myself, thus cannot comment on whether these rumours are valid or not)
    What I would think a bit concerning is that one application trashing a table (deleting all the data) while other applications/users are busy changing data in that table. Why are they changing data that will be immediately trashed after they have committed their transactions? Surely they are wasting time and resources all around (user-side and server-side) by doing work that will be immediately invalidated? This kind of points to me to a database or application design problem.

  • How to read the output of 'tarantella license query' command?

    I'm trying to track my license usage (to better determine when to buy new licenses, and to track usage over time).
    When I issue the 'tarantella license query command, this is typical of the output I see:
    [root@sgdserver ~]# /opt/tarantella/bin/tarantella license query
    License usage at: Mon Feb 11 14:03:53 EST 2008
    Type                In use / Total
    Base                6      / 230
    UNIX                4      / 230
    Mainframe           0      / 230
    Windows             0      / 230
    AS/400              0      / 230
    [root@sgdserver ~]#What is the above saying? Is it saying that I am using 10 licenses out of my 230, or am I just using 6 licenses? In other words, do I add up the numbers or just use the highest one? Or do I just have to worry about the 'Base' license number?
    Thanks.

    The base license is the number of users that are logged into a webtop.
    From there you count then connectivity type.
    So you have 6 webtop licenses out of 230 consumed and of those 4 users have launched UNIX sessions out of 230 you have licensed.
    hope this helps.

  • SQL * Plus commands using JDBC

    Hi,
    Is it possible to run SQL * Plus commands using JDBC?
    Like Describe mytable , @mysql.sql etc....
    Pl. let me know any hints or way to handle it..
    Regards,
    Kavi

    like masuda1967 said, and you have MetaData objects for ResultSets as well.
    @something.sql you can call using CallableStatement objects, look it up in jdbc docs....

  • How to echo the SQL command in JDBC?

    When we use a PreparedStatement and execute query, is there a way to get the exact SQL command
    sent to the server without any '?' marks? That would be an aid in debugging. Or is such a facility server-pecific? I am using MySQL with JDBC.
    Thank you.

    Why I want to see the SQL command now is that I am getting a nagging SQLException in the following
    code. Would someone tell me why this code fails?
    //Database connection successful.
    //conn and pstmt are successfully created.
    //variables 'pid' and 'subfolder' are already evaluated, and confirmed that they have valid values
    int sub_id = 0;
    String myquery = null;
    ResultSet rs1 = null;
    try{
    myquery = "SELECT j15c_directory_id FROM j15t_directory WHERE (j15c_parent_id = ? AND j15c_name = ?)";
    pstmt = conn.prepareStatement(myquery);
    pstmt.setInt(1,pid);
    pstmt.setString(2,subfolder);
    rs1 = pstmt.executeQuery();
    rs1.next();
    sub_id =rs1.getInt("j15c_directory_id");
    catch(java.sql.SQLException e1){
    System.err.println("SQLException: " + e1.getMessage());
    The error message I'm getting is "Before start of result set ".

  • Problem with executing SPARQL command using jdbc or jena in Java

    Hi everybody
    I am new to Oracle and SPARQL, so I'm sorry if my question is the elementry one!
    select s, p, o  from table(SEM_MATCH( '(?s ?p ?o) (?s <htt...> ?o) ', SEM_Models('OWlTEST'), null, null, null ))
    I have an SPARQL command which runs on Oracle correctly and returns 8 Rows. So far so good!
    I tried two ways to use this command in java code:
    Using java.sql.jdbc
    stmt = conn.createStatement();
    rs = stmt.executeQuery(...the whole command above ....);
    if (rs.next()){
    System.out.println(rs.getString("O"));
    Problem: resultset returns only One row, which is the first row, althogh in debug mode I can see validRow=8!!!
    Using com.hp.hpl.jena
    Model model = ModelFactory.createDefaultModel();
    String queryStr = "PREFIX : <.....> SELECT ?s ?p ?o  FROM  <...> WHERE {?s prefix:property ?o}";
    Query query = QueryFactory.create(queryStr);
    QueryExecution qexec = QueryExecutionFactory.create(query, model);
    com.hp.hpl.jena.query.ResultSet results = qexec.execSelect();
    for (;results.hasNext();) {
    Problem: it returns nothing!!
    Do you any Idea,
    Thanks in advance
    Sara

    Sara,
    I don't know about SPARQL not about jena, but for Java you need to change:
    {code}
    if (rs.next()) {..
    {code}
    to
    {code}
    while (rs.next()) {..
    {code}
    Otherwise you just fech and see only first row.
    Look at : http://www.java2s.com/Code/JavaAPI/java.sql/ResultSetnext.htm
    HTH
    Thomas

  • How to use a global variable for reading a query resultset in JDBC lookup?

    Hi Friends,
    Using JDBC lookup, I am trying to read from a table Emp1 using a user defined function. In PI 7.0, this function returns values of a single column only even if you fire a " Select * " query. I am planning to use a global variable(array) that stores individual column values of the records returned by a "select *" query. Need pointers on as to how a global variable can be declared and used to acheive the above scenario. Kindly explain with an example. Any help would be appreciated.
    Thanks,
    Amit.

    Hi Amit,
    Sounds like a good idea but then you would need an external db and update the table in a thread safe way !.
    Regarding your question as to how to work with global variable please refer https://www.sdn.sap.com/irj/scn/weblogs?blog=/pub/wlg/1352. [original link is broken] [original link is broken] [original link is broken]
    Rgds
    joel

  • Two select query in sender JDBC adaptor

    Hi
    We are doing JDFC-RFC scenario, in which i need to fetch the data from two tables (header  and item table) whch correspondes to the 2 table parameter of RFC .
    Any clues how to configure sender jdbc CC having  2 select query ??????
    Regards
    Vijay

    Swatantra,
    You can have a look at the below URL for more info on JOIN.
    http://www.w3schools.com/sql/sql_join.asp
    Best regards,
    raj.

  • How to handle transaction control--- in the dbms query or in JDBC? or BOTH?

    Hi all,
    we have a servlet application which do insert, update to a few sybase tables. so far we don't have any transaction management control in either store procedure or in JDBC call. i like to know where should we enforce this control logic? in both place or either one is enough?
    thanks!!

    according to your answer, is it safe to say that we
    should NOT
    handle transaction control in both query and JDBC
    call? i am on the side of JDBC
    program control. However our manager feels that if we
    handle it in two place, we could be more error-proof.
    i don't know how to convince him that only one place
    could make it work. Double your rollbacks double your fun! Odd that a manager is getting involved at this level...
    Providing transaction control at both places, as a rule makes absolutely no sense at all (to me). I actually believe that this would be far more error-prone (not error-proof). It's really a logistics issue. When you are working on the Java code, you won't have the stored procedure(s) code right there. While you may design it masterfully at first, as maintenance occurs, the mastery can easily be lost as assumptions are made on when and where commit or rollback processing is going to take place. The end result would be a system that could easily corrupt the logical integrity of the database.
    If you have to make a decision up front, and you believe performance will ultimately be a concern, then your decision should be to handle transaction management within the stored procedure(s). However, this decision will make the stored procedures far more complex than what the DBA or application staff is familiar with. You would also have to take some care to release resources as appropriate within the Java code.
    If you decide to manage transactions within JDBC, it is possible that you will have to move a portion of transaction managment to one or two of the stored procedures. This would be a 'fix' for a poorly performing functionality, and you would simply take care to limit this as much as possible.
    I wish I could guide you specifically, but I'm working at 20,000 feet related to your specific application needs.

  • Providing Query statement in JDBC  adapter

    HI experts,
    Everybody knows we can provide Query to JDBC adapter by two ways...
    1st way is by constructing query as XML structure..
    2nd way is by giving exact query (Select * from tablename )by SQL_query in access ...
    I like to know the performance of these two ways...
    Regards,
    Sasitharan

    In XI version 3.0 there is only one way to do lookups - manually in the form of an exit in the mapping process. A user exits must be written in Java.
    There are a couple of considerations about performance that must be kept in mind besides just the question of “SQL Statement” while implementing a database lookup using a JDBC adapter:
    1.     The mechanism for database lookup
    There are 2 approaches – Direct, Indirect
    In Direct approach you poll the external table hence this may lock database for access to other users, also it is an intrusive approach. In indirect approach database table is replicated and the replicated table is accessed. The second approach is recommended for performance reasons.
    2.     Does the data to be looked up change frequently
    If data does not change frequently than pull in data and keep a copy locally – as this will improve performance
          2. It is possible to access an external database from within the mapping step of XI utilizing
    A.     regular JDBC constructs
    B.     utilization of J2EE JDBC Connector
    Approach 2 is recommended as it is more efficient because of Connection pools.
    There is no concept or need to XML code here. The Java code that executes the lookup, would call the sql statement, this java code can  be referenced from within a user-defined function in the graphical mapper or from within XSLT.
    Hence you need SQL statement in J2ee JDBC Connector to get the best performance.
    Refer to URL
    http://searchsap.techtarget.com/tip/0,289483,sid21_gci1246926,00.html#
    to understadn how to configure the JDBC Connector Service to perform database lookups
    Let me know if this helps.

  • Copy command from JDBC

    Hi all,
    I am currently trying to use the copy command to copy data from a text file into a database table using JDBC. In my Java application I am attempting to execute the SQL copy node from 'node.txt' with Delimiter ' '; where node is the name of the table. After the SQL is executed the update count is 0.
    However, when I run the same command from the SQL console in pgAdmin (I am using the PostgreSQL database) the command works correctly and as expected. I don't understand what the problem is as the command is the exact same. Has anyone else has this problem or know how to fix it?
    Any help would be much appreciated.
    Thanks,
    Martin

    My JDBC code is below:
    Thanks.
    public void copyTableFrom(
              String tablename,
              String mode,
              String path //the "absolute" path of the file
              String qrystr = "copy " + tablename + " from \'" + path + "\' with Delimiter ' ';";
              this.db.nonQueryCmd(qrystr);
    public void nonQueryCmd(String cmd)
              try {
                   this.st = conn.createStatement();
                   this.closeStatement();
              } catch(SQLException sqle) {
                   System.err.println("error occurs when execute " + cmd);
                   sqle.printStackTrace();
                   this.exit_nicely();
    public void exit_nicely()
              this.disconnectDB();
              System.exit(1);
    public void disconnectDB()
              try {
                   this.conn.close();
              } catch (SQLException e) {
                   System.err.println("Closing connection to database " + dbname + " failed");
                   e.printStackTrace();
                   System.exit(1);
         }

  • Startup command in JDBC

    How can i execute the startup and recover commands for oracle usingJDBC OCI driver

    One way to control a database when the are a 'lot' of attributes is to create a named attribute table. So instead of this
      table X - fields: name, color, width, height, finish, texture, cost
      data X
             bear, brown,       14, 14, shiny, fuzzy, $14
             top,  red and blue, 3,  3, shiny, hard,  $1
    .one uses this
      table X - fields: name, id, cost
      table Attr - fields: X_id, name, value
      Data X
             bear, 1, $14
             top,  2, $1
      Data Y
             1,  color, brown
             1,  width, 14
             1,  height, 14
             1,  finish, shiny
             1,  texture, fuzzy
             2,  color, red and blue
             2,  width, 3
             2,  height, 3
             2,  finish, shiny
             2,  texture, hard
         The trade off is ease of use in programming vs more complex logic and possibly more storage space (noting that name in Y could be a number saves on space.)
    This might actually result in saving space if the attribute values are sparse - not all of them have values.
    This can slow down searches and make queries slower. But that greatly depends on the query. There are cases where this can make it substantially faster. That depends on the nature of the data and the needed queries.
    An alternative to this is to make a table for each attribute. Once again there are trade offs there. And it probably isn't applicable for 'attributes for a house'.
    Notice in the above that cost is not part of the attribute table. This is a design decision that once again is driven by the needed queries. Presumably cost is an important query item, it will always exist and will always be returned for any query. So it can remain in the main table.
    An additional table can be used - an attribute name table. Doing this, and writing code which supports the use of that makes it extremely easy to add new attributes.

  • Execute SQLPLUS command using JDBC

    Hi,
    I was wondering if its possible to execute sqlplus command (eg set define off, change date format ..etc) using JDBC ?
    Can anyone please post me some sample codes about this ?
    Any help will be appreciated

    Hi,
    But the Runtime.exec() and the JDBC application have
    their own connection to the database, and the sqlplus
    commands that i need to run are session based (only
    valid during the connection). eg set define off
    How do I overcome this ?
    Huh?
    You put anything you want into a input file. You feed the input file to sqlplus. If there are results then you put them into an output file.
    None of that has anything to do with JDBC nor even with java. When you call Runtime.exec() you are running a completely different process. What you do with that process is up to you.

  • Java Web Analyzer security hole in SQL Query Spreadsheet using JDBC-ODBC bridge

    Hi,<BR><BR>I use Hyperion Analyzer 7.0.1 on Windows 2003 and relation database DB2 v8.2.<BR><BR>I did:<BR>1. log in to Java Web Analyzer<BR>2. button New<BR>3. Select Layout: Custom Report<BR>4. from toolbar pull down to desktop "SQL Spreadsheet" option<BR>5. "Enter SQL Query" window opens, from JDBC Driver drop down window select "JDBC-ODBC Bridge"<BR>6. in "JDBC Connection String" window replace "db1" string with database name<BR>7. leave JDBC Username and JDBC Password empty (this is default)<BR>8. click on "Test Connection" button.<BR>9. "Test Connection" window opens with message "Connection Succeded"!!! So connection to database without password succeeded.<BR>10. in "SQL Query window" write any SQL you wish and Database will execute the SQL.<BR><BR><b>Conclusion: Connecting Analyzer with SQL Spreadsheet option to relation database DB2 is possible without password.</b><BR><BR>Question: Is there any way to prevent users from executing "SQL Spreedsheet" option?<BR><BR>Thanks,<BR>Grofaty

    try
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    Connection con = DriverManager.getConnection(dsn,"guest","guest");
    OR DriverManager.getConnection(dsn);
    System.out.println("Conection's opened");
    catch(ClassNotFoundException cnfe)
    System.err.println(cnfe);
    catch(SQLException sqle)
    System.err.println(sqle);
    try that code and double check you DSN Name . it's a good practice to greate a system DSN.
    i hope that helps.
    FEEL FREE TO ASK. WON'T BITE U
    ABDUL

Maybe you are looking for

  • Photoshop CS Won't Open

    I have Photoshop CS and have been using it for a long time on this computer - and it has always been fine. I'm now trying to open it - and it basically won't open. The initialization takes forever (it was always long - but is REALLY long) and then I

  • FaceTime audio

    when using facetime on ipad 2 connected to digital av adaptor I get video on tv but audio only comes from ipad, when using skype or itunes audio comes out of tv, is this an issue that can be resolved?

  • Cannot launch J2ee server, pls help

    I am not able to launch j2ee server. I have followed instructions in Installation file and installed software in correct directories and have set up environment variables in autoexec file as follows: set J2EE_HOME=c:\j2sdkee1.3 set JAVA_HOME=c:\jdk1.

  • USR02 table is corrupted

    We use version 4.7X100 of SAP. The problem I have got is the USR02 table is corrupt and do not know what to do. For example, when I add new parameter in a user's master record, the rest of already existing parameters vanishes after saving the master

  • BB id in 2 devices?

    I have used same id in 2 of my BB10 devices.why arent the apps autoupdated in both?