×

Loading...

Topic

This topic has been archived. It cannot be replied.
  • 工作学习 / IT技术讨论 / help. after insert, how can I select immediately. help, help
    I have some user personal data need insert to db and get the insert index immediately to create dynamic presentation., but right now, I can only insert the data into databse, but can not get the correct query result set just after the insert command was executed. I only can get the correct resultset in a later time. (the query sql command is just the same.) I forward the select query into another page, but it does not work either. How come. the data did not commit? or some other question.
    please help me
    • no body have this kind of experience? jsp /java expert come in.
      • If your database is MS SQL Server, you can get it by "SELECT @@IDENTITY AS Identity".
    • What do you mean by saying "a later time"? Check the jdbc connection, and set auto-commit to true. Or if you use some other codes above jdbc to do all database operations, check these codes to ensure that they donot' cache query results.
      • where's the code.
        I can reach the id generated by system in another session.
      • maybe I can do the job in another connection, but does not that waste the resources. by the way, I am not familiar with the CS and also, I have no programming experience, I started do it half year ago.
        but i want to make it. in this project, maybe we can show an attractive mock up design to the client, so , my first job is do business for myself.
        right now, I only use jsp and java bean. maybe later, if I get the project, maybe I will use JMS and EJB.
        by the way, bloor, we almost landed at the same time. I start learn java two months late, how about you..
        another question, how to find the config in set the auto-commit.
        in my opinion, if the sql command is still in the buffer, other users can not get the new insert record, but you can, for it is in your buffer, but in my problem, it reversed. how come.
        • I started to use Java from last Nov. when I join my send company in Canada. I don't know if it's a correct choice, although I can do java years ago.
          You should be using interface java.sql.Connection, right? Check the java api at sun.com, you will find these methods:

          1. getAutoCommit(): Gets the current auto-commit state.

          2. setAutoCommit(boolean autoCommit): Sets this connection's auto-commit mode.
          • thank you. i will try that method, but before I get your suggestion, I tried to add another sql command just execute the commit after the insert one, I still face the bug as it was.
            • gemlan 请进
              你好,我也在学JAVA,我们可以互相交流一下吗?
              我的MAIL :tt28tt@hotmail.com
          • u r right,I think