One connection for each sql statment?

Hi there!
Can I use only one connection for several stataments or prepared statements? or
Do I have to use 1 connection for each statement?
After an insert, how can I know row id assigned by SQL Server (authonumeric)?
Thanks a lot in advanced.
LJ

>
One of the updates to the JDBC API in Java 1.4 has
been a getGeneratedKeys() call, which (if you
requested them) gives you the keys that were
generated.
Good idea here, evnafets. I tried it with Oracle recently, but it didn't work. I wasn't aware of a driver that did implement it. I'll try MySQL to see. Thanks.
You would probably need an up to date JDBC driver, but
I have seen this work in mySQL. Maybe it might solve
this problem once and for all.
Apart from that you can try select @@Identity from the
server to get the id
Or that old awful, unreliable hack of select (max)
(shudder)
Any other suggestions?Some folks like having a single table for key generation. Keys are unique across all tables that way. Using that scheme with before insert triggers can mean just a query on the key table. - MOD

Similar Messages

  • One connection for each request!trans

    Hi there,
    We migrated a big application from classic toplink to EJB 3, glassfish, EclipseLink. Some big module is still using classic toplink queries for a lot of things. As we didn't have the resource to change everything to pure ejb & jpa, we tried a couple of "tricks". They kind of work (in production), but I noticed that there is one connection for each db request.
    It stills works fast enough, thanks to Glassfish connection pooling. But I guess this is horrible. Regarding transactions too...
    Here is how I get a UnitOfWork:
    JpaEntityManager jpaEntityManager = JpaHelper.getEntityManager(entityManager);
    UnitOfWork unitOfWork = jpaEntityManager.getUnitOfWork();
    Here is some eclipselink query which is causing thousand of db queries and acquiring about the same number of connections :
    return ((Collection) unitOfWork.executeQuery(readAllQuery));
    thx, Yannick

    Hello,
    ReadAllQueries will always go to the database by default to ensure that all the results are returned. So unless you are using inmemory query options, you will always see the same number of queries as executeQuery calls when using ReadAllQuery objects.
    As for connections, the default is for connections to be obtained as they are needed, and then released when no longer needed. By default, EclipseLink/TopLink will use a read connection pool and obtain and release for each read query that is done outside of a transaction. When in a transactional context (ie reads through a uow where a transaction was started and changes made), reads will go through the write connection - this is done to ensure that transactional changes are picked up -and these will not be put into the shared cache until the transaction completes. So all reads done in the same uow while in a transaction will use the same write connection, since the uow needs to hold onto while the transaction is active anyway.
    How are your transactions demarcated and the EntityManager obtained?
    Best Regards,
    Chris

  • Get only one row for each kind of a column

    hi there!
    i have a little problem.
    I have a table with 10 columns. One of them has repeated values. My goal is to get all the rows with this column only one time for each values that it has.
    Ex:
    Col1 Col2 Col3
    A A A
    B B B
    C A C
    D C D
    Column 2 has repeated values. My goal is to get:
    A A A
    B B B
    D C D
    Only one time each value of column 2.
    Thanks guys! ;)

    SQL>  CREATE TABLE Tbl (col1 VARCHAR2(1),col2 VARCHAR2(1),col3 VARCHAR2(1));
    Table created.
    SQL> INSERT INTO Tbl VALUES ('A','A','A');
    1 row created.
    SQL>              INSERT INTO Tbl VALUES ('B','B','B');
    1 row created.
    SQL>              INSERT INTO Tbl VALUES ('C','A','C');
    1 row created.
    SQL>              INSERT INTO Tbl VALUES ('D','C','D');
    1 row created.
    SQL> commit;
    Commit complete.
    SQL> SELECT * FROM tbl t1
      2  WHERE
      3  rowid=(SELECT min(rowid)
      4         FROM tbl t2
      5         WHERE t1.col2=t2.col2);
    C C C
    A A A
    B B B
    D C D
    SQL> SELECT * FROM tbl t1
      2  WHERE
      3  rowid=(SELECT max(rowid)
      4         FROM tbl t2
      5         WHERE t1.col2=t2.col2);
    C C C
    B B B
    C A C
    D C DEdited by: Saubhik on Aug 3, 2010 1:31 AM

  • Mail having more than one notification for each mail received

    ever since I've upgraded to Yosomite X from Mavericks the Mail built in app is been acting weird. As Soon As it is connected to the internet the Mail Application collects emails n i keep on getting notifications at the top right bar for each single mail i would get minimum two notifications if not four or three. Am getting annoyed by this issue especially if ur waiting for an email n hyped about it i would be disappointed lol.
    Plz if anyone has a solution for this offer you're help and it is well appreciated.

    Mail preferences under Compose tab. Set which account to send mail from, or set it to use the highlighted account.
    You might also verify in Mail preferences under Accounts, that each account has it's own SMTP server. Be sure the correct one shows for each account. I would also check the box to use only that server for that account, which will insure that the correct server and only that server will be used for the account. Otherwise if the SMTP server for the sending account fails, it will just switch to another account's server.

  • Multi-column Index vs One index for each column

    Hello everyone,
    i have one table about 20 000 000 rows, some developers have to generate reports on it and i want to create indexes on this table.
    The table has 34 columns, no primary key, no unique keys.
    The "where..." clause of the reports usually use 8 columns but some reports uses 8 + some other columns.
    can any one help me on what kind of indexes do i have to create?
    1. one index for each column used in "where clause"
    2. one index for 8 columns and some other indexes for other used columns
    3. one index for all columns
    or something else etc...
    br flag

    i have one table about 20 000 000 rows, some developers have to generate reports on it and i want to create indexes on this table.
    The table has 34 columns, no primary key, no unique keys.
    The "where..." clause of the reports usually use 8 columns but some reports uses 8 + some other columns.
    can any one help me on what kind of indexes do i have to create?
    1. one index for each column used in "where clause"
    2. one index for 8 columns and some other indexes for other used columns
    3. one index for all columns
    or something else etc...What's the version of your data base? what kind of database you have, DWH or OTLP? The answer might depend on the type of database as far as bitmap indexes might suit or might not depending if you are runing DWH or OLTP kind of database
    Let me suppose that you are runing OLTP database and you have a where clause with 8 columns.
    1) are all those where clause equalities (where col1 = and col2 =) or there are inequalities?
    2) could you evaluate the most repetitive columns?
    3) could you know the column that could have the best clustering factor (the column which most follow a certain order in the table)
    Based on that I would suggest to create one b-tree index having 8 columns (even though that it seems for me to high) this index should follow the following points:
    1) put the most repetitive column at the leading edge (and compress the index if necessary)
    2) put the columns that are used in equalitity predicate first
    3) put the column having the best clustering factor first
    The most precise index you have the best access you could gain.
    Of course that you have to know that an index access is not always good and a FULL table scan is not always bad.
    Best regards
    Mohamed Houri
    www.hourim.wordpress.com

  • How do I program a NI 6602 card to send trigger pulses, one at each output port, triggered by an input trigger signal, using only one counter for each output port?

    Hello,
    I have managed to program a NI 6602 card in LabView to send pulses on three different output ports, one pulse on each output port (with individually chosen delays) for each input trigger pulse coming on a separate input port. It is the DAQmx Create Channel (CO-Pulse Generation-Time)-VI that I have used for this, see attached code. However, this VI controls both pulse delay and pulse width, and therefore uses two counters for each output port (although you only specify one counter in the VI input signals), as I understand.
    In my application though, I only need to have the delay chosen, the pulse width can be arbitrarily short, and thus I should only need one counter for each output port. How do I accomplish to program this in LabView?
    Best regards,
    Claes
    Attachments:
    Configure Side Camera Flash 1 Triggering.vi ‏47 KB

    Well you're welcome to do that--it will work just fine as long as you are configuring a start trigger.
    <rant>
    However, personally I really don't like putting multiple counter outputs in the same task.  I have seen so many people assume that the counter outputs would be synchronized due to having them in the same task when this is not the case (you need to configure a start trigger in order to synchronize the counter outputs even if they are in the same task).  This is the only case I can think of where multiple channels in a DAQmx task are not automatically synchronized.
    As an example:
    Running this on my PCIe X Series gives a measured 2 edge separation of 1 ms + {7.78 us - 10.11 us}.  This would likely be much worse on a bus with more latency (e.g. USB).
    The resulting output is close enough to what you might expect that it might go unnoticed, but really these counter outputs are not synchronized and it would be easy to glance at the code and not even think twice about it.  For the small amount of extra work on my end to create a separate task for each counter, it really clears up some ambiguity about what the counters are actually doing.  For me it's worth it.
    So again, for your case there really isn't a problem with having the counters in the same task since you are using an external start trigger anyway.  I have just gotten in the habit of avoiding doing this.
    </rant>
    Best Regards,
    John Passiak

  • How can I have one row for each object?

    Post Author: farnaz
    CA Forum: WebIntelligence Reporting
    I have 3 objcts that one of them is ID and second one is internal code and the third one is quantity.There is more than one value for each ID (becouse of internal code).I want to create a report based on ID and quantity (not based on internal code).I make a break on ID but the result shows me more than one row for each ID.so how can i have just one row for each ID?
    another question:
    how can I post screen shot of the results to my messag in forum?

    Post Author: jsanzone
    CA Forum: WebIntelligence Reporting
    farnaz:
    Have you tried to omit "internal code" from your grid?  In normal circumstances, if you have "ID" and "Quantity" on the grid, then WebI will on its own summarize Quantity based on ID, however, this is provided that Quantity has been set up as a measure (or metric).  The quickest way to tell if Quantity is a metric or not is to observe the color of its icon when you look at it in the data panel.  If it is a purple (or sometimes appears as pink or fuscia) dot, then it's a measure, but if it is a blue box then it is a dimension.  If you need Quantity as a measure then this will have to be modified at the universe (make it look like "sum(Quantity)" in the select phase of the object, and insure the object is defined as a number....

  • When we drilldown at document level it displays one record for each cube

    Dear Experts .
    The users want to see the report by status for the order detail report at document level it displays one record for each cube .
    They want to see the single line for the order quantity , Amount, Billing quantity delivery and amount along with the Sales order number , billing document number billing date , delvert date ..et in signgle line. ( Sale order DeliveryBilling)
    When we are doing on Multiprovider recording displaying from each cube.
    We have tried with Constant selections and it is not giving the required results m since these want to see by status. Due to huge data performance reasons we re unable to use it .
    Please provide your valuable inputs.
    Thanks,
    Mahesh.

    Mahesh,
    If you want to get detail data with respect to Sales order - delivery - Billing, on top of Multiprovider you can come up with Constant selection.
    But I am not clear that why constant selection is not working properly, can I have some light on that.
    Probably, you are struggling with multiple records .
    I suggest you to go with end routine and map all fields to one IC and do reporting on that single IC, then your requirement will fulfill.
    But here we need to take care of performance issues and process chain scheduling wile loading deltas.
    If Multiprovider is not working properly , then try with Infoset(If you have more than 2 ICs it not possible).
    Regards,
    rvc

  • MS word It prints one file for each section of the document

    With MS word (2004 and 2008)It prints one file for each section of the document.
    somebody can help me with that????

    Please post Office related questions on Microsoft's own forums for their Mac products:
    http://www.officeformac.com/productforums

  • Multiple parameters one row for each record

    I have this query I want the user to be able to allow the user to enter multiple MATL_CODE_MOD as a parameters, the problem is that the GURMAIL table have multiple records one for each GURMAIL_MATL_CODE_MOD, so it will give me duplicates.. How I can code this, so I can allow the user to enter multiple MATL_CODE_MOD codes, and have only one row for each record...
    and GURMAIL_MATL_CODE_MOD in ('8IBC','8IBD')
    select
    spriden_id,        
    spbpers_name_suffix   name_suffix,
    spbpers_name_prefix   name_prefix,
    spriden_last_name     last_name,
    spriden_first_name    first_name,
    spriden_mi            mi,
    srbrecr_term_code,
    srbrecr_majr_code,
    srbrecr_program_1,
    saturn_midd.utlq.f_matl_code_type(srbrecr_pidm)
    FROM
    saturn.srbrecr,
    saturn.spriden,
    saturn.spbpers,
    SATURN.SPRADDR,
    general.gurmail
    WHERE
    spriden_pidm = srbrecr_pidm
    and gurmail_pidm = spriden_pidm
    AND spriden_pidm = spraddr_pidm 
    --and srbrecr_term_code = decode(p_term  ,'%',SRBRECR_TERM_CODE,p_term)
    and spbpers_pidm = spriden_pidm
    and spriden_change_ind is null
    --and gurmail_matl_code_mod
    and SRBRECR_PROGRAM_1 = 'CMQ'
    and GURMAIL_MATL_CODE_MOD in ('8IBC','8IBD')
    --AND SPRADDR_ATYP_CODE = 'CM'
    AND SPRADDR_STREET_LINE1 IS NOT NULL;

    Hi,
    SELECT DISTINCT ...will keep duplicate rows out of the result set.
    Depending on your data, another possibility might be to not join the table that contains GURMAIL_MATL_CODE_MOD. Do an EXISTS sub-query on that table instead.
    If you need more help, post some sample data from all the tables, and the results you want from that data.
    Simplify, if possible, You can probably post a problem with 2 or 3 tables, each with 2 or 3 columns, that will have the same answer.
    Edited by: Frank Kulash on Apr 22, 2009 2:28 PM

  • One controller for each usecase?

    I'm using a mvc design pattern for my webapp.
    In some of the books I've read it seems like they are suggesting to use one controller for each of the usecase. Is this the right way to do it?
    For me it seems like you get so many classes. If you are dealing with a User, and has to modify info about a User, are you going to have a
    - registerUserController
    - updateUserController
    - deleteUserController
    Or should you have an UserController containing an if-else statement and have 3 functions, one for each of the usecases according to the User.
    It seems like the advice is that when you have many if-else statements you should instead use interfaces. Is that correct?
    Thanks

    Thanks for a very good explanation!!
    I'll explain my code a bit more detailed, so that I'm sure this is how you think I should do it.
    - I'm using a frontcontroller and the Command/Action pattern.
    - I'm not using a applicationcontroller.
    - A controller is typically a servlet.
    In my app I'm using an action class and an controller (servlet) class for each usecase. So this is the way to do it?
    public class FrontControllerServlet extends HttpServlet {
    private HashMap actions;
    private ModelAndView mv;
    public void init() throws ServletException {
    // Action hashtable
    actions = new HashMap();
    // Makes action objects by putting controller objects into action objects
    RegUserAction rua = new RegUserAction(new RegUserController());
    UpdateUserAction uua = new UpdateUserAction(new UpdateUserController());
    // Puts action objects into hash table
    actions.put(rua.getName(), rua);
    actions.put(rha.getName(), uua);
    protected void processRequest(HttpServletRequest req, HttpServletResponse res){
    op = request.getParameter("op");
    Action action = (Action)actions.get(op);
    ModelAndView mv = (ModelAndView) action.perform(request, response);
    } //End FrontController
    public class RegUserAction extends Action{
    public RegUserAction (Controller c) {super(c); }
    public String getName() { return "regUser"; }
    public Object perform(HttpServletRequest request, HttpServletResponse response) {
    return c.handleRequest(request, response);
    } //End RegUserAction
    public class RegUserController implements Controller {
    public Object handleRequest(HttpServletRequest req, HttpServletResponse res){ 
    String userName = request.getParameter("userName");
    String userPwd = request.getParameter("userPwd");
    ... Registers user in database
    ....Returns a ModelAndView object confimrming that the user has successfully been registred in the database.
    } //End RegUserController
    public interface Controller {
    public Object handleRequest(HttpServletRequest req, HttpServletResponse res);
    Does it seem like I'm on the right track?

  • Create one connection for multiple dynaset reads

    I am using VC 6.0 with the OO40 class. I am processing a text file in a console batch mode. The file can contain 1 record or hundreds of records. I would like to open the db connection/session once and read the database multiple times - one for each record being processed. What is happening is that the first record is read, and processed. The subsequent records are not read and the dynaset still points to the first record. I have the dynaset read process in a function - so that the dynaset is destroyed and recreated everytime. What am I doing wrong.

    As for your question: it is discussed in sAP online help:
    http://help.sap.com/saphelp_erp60_sp/helpdata/en/c6/f841f24afa11d182b90000e829fbfe/frameset.htm
    Sorry I misunderstood your question.
    The above mentioned solution won't create one single TO from multiple TR.
    Edited by: Csaba Szommer on Aug 11, 2010 9:46 AM

  • New OLAP connection for each BEx query?

    Hi,
    I am wondering whether it's really necessary to create for each BEx query a new OLAP connection in BO 4.0.
    This is the BICS connection as far as I know. But this would result in a lot of OLAP connections...
    Thanks!

    One OLAP connection is enough for one BW system.
    You can also dedicate a OLAP connection to one query if needed.

  • IPhone Ad Hoc - One build for block of UDIDs or one build for each UDID?

    Hello.
    For ad hoc distribution, do I need to create a new unique build for each of the UDIDs from my potential testers? Or just one time for the entire set of UDIDs?
    Please set me straight, I've been searching for this answer, but could not find anything.
    Thank you so much.

    You must add each UDID to your distribution provisioning profile in iTunes Connect. Once you have done that, you can use a single .mobileprovision file and a single binary for all provisioned users. You do not need to build a version for each user.

  • TS1424 I have 2 iPads and one Id how can I create one id for each iPad?

    I have two iPads and when I download an app it appears on both iPad , how can I have two ids, one for each iPad ?

    Why would you want two IDs? This will cause some problems.

Maybe you are looking for

  • Web access doesn't work for AP1231

    When I set up a username with privilege level 15 the web prompt just keeps blinking back at me. I can log on via telnet with no issues using the username and it puts me right into enable mode without the enable password. This problem happens with jus

  • Ongoing issue with my iPhone.

    So here's the story from the beginning. Just before Christmas 2008, my phone completely locked up while I was away from home. Couldn't turn it off, couldn't do anything. I didn't freak out too much because I've had multiple issues with it locking up.

  • Album FLow stopped working in iTunes

    All of a sudden Album flow says "Itunes is unable to browse album covers on this computer". I uninstalled and reinstalled iTunes and that was not help. I have it rebuild the library and that was not help. So what do I do now?

  • EAN codes to be matched automatically

    I have a scenario where I want the EAN codes 16 digit in the IDOC automatically picking up SAP code and creating the order inbound. Somehow its not happening. I keep getting a message description of Item is missing, I maintain the text descrption in

  • Twitter apps suddenly bring me back to main screen when in use

    I am currently facing a problem with my iphone. Whenever I am using twitter apps, be it twwetdeck, echofon, or twitter for iphone..the phone would sometimes bring me back to my main screen when the apps are in use. Does anyone of you have suggestions