Question about app design - database + session object in JSP

hi all
i am studying this application built mostly with servlets and JSPs, and there are several questions i want to ask your guys' opinions about it.
first of all, i noticed that the application hits database to get/save data very frequently. from one page to another it would save data collected from user to the DB, and retrieve data from DB to display on the next page. it does this a lot. would this decrease the overall performance of the application, i mean a DB hit requires network traffic overhead, wouldn't it be better if all data collected from user are stored in a session object temporarily, and all the data that are displayed on those pages retrieved at the start time? and do one save process in the end. it uses Oracle DB if it makes any difference. should we try to avoid db hit as much as possible?
my next question is that is it good approach to keep information in session object? even if there is a lot of data to keep?
another question is the db connection. in a pooled environment - weblogic server, we would use JNDI in the code to get connection from the pool, we use it and close it. when we close a connection with close() method, what really happens? does this connection gets return to the pool or it is being destroyed completely.
i know this is a lot to ask, i appreciate your help very much. looking forward to seeing some feedback.

No, I don't have tables of values. I have a java 1.5 enumeration, like for instance:
public enum VelocityConvention {
   RELATIVISTIC,
   REDSHIFT;
}and a class Velocity that contains a convention and a value like so:
public class Velocity {
   public VelocityConvention getConvention() {...}
   public double getValue() {...}
   public void set(VelocityConvention conv, double value) {...}
}When I persist the Velocity class to the database, I want a field called convention that holds the appropriate value of the enumeration. That much is done how I explained before.
I want to have a selectOneMenu for setting the convention. Via trial and error, I found that MyFaces wasn't able to automatically convert from a string back to a proper VelocityConvention enum constant. It can, of course, convert from the enum to a string because it just calls toString(). But I need both directions for any UIInput element I use, be it a selectOne, or just a straight inputText.

Similar Messages

  • Question about app design with JSF

    I'm new to JSF and have been using MyFaces in combination with Tomcat and Hibernate to write a web application for my institution. We have a fairly clean model implemented and our hibernate persistence layer is also looking good. I'm running into trouble making a clean view layer with JSF. Namely, I can't seem to avoid creating lots of classes to get a given job done.
    As a for instance: I have quite a few enumerations representing various units of measure, conventions, etc. To persist them in the db with hibernate, I needed to make a converter class to convert the Enums to strings. I wrote a class using generics that could convert any enum to strings appropriately given a class object you pass into the constructor. Well, hibernate needs a no arg constructor so it can instantiate one automatically, so I had to make a subclass of this converter for each enumeration I have in my model. Couldn't see a way around it.
    Now, using JSF, I'm needing to implement another converter for enumerations in order convert back and forth from strings. Same deal. I could use a single class to get the job done. The problem is, in the faces-config.xml where you define your converter classes, it doesn't look like I can have 2 converters defined with the same converter class.
    i.e.:
    <converter>
    <converter-for-class>commons.astronomy.Epoch</converter-for-class>
    <converter-class>tools.webapp.EnumConverter</converter-class>
    <property>
         <property-name>enumClass</property-name>
         <property-class>java.lang.Class</property-class>
           <default-value>commons.astronomy.Epoch</default-value>
    </property>
    </converter>
    <converter>
    <converter-for-class>commons.astronomy.VelocityConvention</converter-for-class>
    <converter-class>tools.webapp.EnumConverter</converter-class>
    <property>
         <property-name>enumClass</property-name>
         <property-class>java.lang.Class</property-class>
            <default-value>commons.astronomy.VelocityConvention</default-value>
    </property>
    </converter>MyFaces seems to associate both Epoch and VelocityConvention with the second configuration of the EnumConverter class. So, the long and short of it is, here I am again having to write yet another class PER enumeration.
    I could go on with another example, but this post is getting lengthy, so I'll make it short. Some of my model classes are not java beans because it would create inconsistencies to only set some of the properties one at a time. I.E. I need to call a method obj.set(a, b) not obj.setA(a); obj.setB(b). My first thought was to create a custom component for obj so that I can turn 2 (or more) input fields into 1 set call. There are other advantages in reusability, etc.
    Unfortunately, I have several of those situations and am finding myself leaning toward implementing yet MORE classes to make a separate component for each such instance of a non-java bean set of properties.
    What it all comes down to is I seem to be having a class explosion and I'm wondering if there's a better approach to this whole thing. How do you organize a view layer that talks to a model having enumerations and not quite javaBean pattern properties without a class explosion? That's the question I guess.
    Thanks for your patience in reading all of that and any help you can provide!
    brian

    No, I don't have tables of values. I have a java 1.5 enumeration, like for instance:
    public enum VelocityConvention {
       RELATIVISTIC,
       REDSHIFT;
    }and a class Velocity that contains a convention and a value like so:
    public class Velocity {
       public VelocityConvention getConvention() {...}
       public double getValue() {...}
       public void set(VelocityConvention conv, double value) {...}
    }When I persist the Velocity class to the database, I want a field called convention that holds the appropriate value of the enumeration. That much is done how I explained before.
    I want to have a selectOneMenu for setting the convention. Via trial and error, I found that MyFaces wasn't able to automatically convert from a string back to a proper VelocityConvention enum constant. It can, of course, convert from the enum to a string because it just calls toString(). But I need both directions for any UIInput element I use, be it a selectOne, or just a straight inputText.

  • Question about singleton design

    Hi all
    i have a question about singleton design. as i understood it correctly, this pattern garantees us a single instance of a class at any time. in a environment of concurrent access(multiple user access at the same time) , does this single instance put a constraint on concurrency(singleton == synchronization)? i have developed a service object that reads in properties and constructs some other objects. the reason i made it singleton is that i only want this service object to load the properties once. and when it is called to create other objects, it always has one copy of the propertis. making this service singleton, will it limit the threads to access it and construct other objects? thanks for your help.

    If there's no write access to the HashMap, then
    you're thread safe.You were probably typing at the same time as the previous post, which explicitly says there IS write access to the HashMap.
    I don't know what it is, but people seem to have this magical view of concepts. Singleton is just what it is. It doesn't have a magical aura that causes other things to behave differently. A singleton is just Java code that can have thread safety problems just like any other Java code. So to the OP: forget about the fact that this is a singleton. That's irrelevant. Ask if a method needs to be synchronized.
    (And yes, a method that tests if a variable is null and assigns an object to it if it isn't null does need to be synchronized if it's going to have multiple threads accessing it.)

  • Question about app itune, it automatically charge money from my card on Apr/24th, but i have not buy any music or any apps on that day!! what's wrong

    question about app itune, it automatically charge money from my card on Apr/24th, but i have not buy any music or any apps on that day!! what's wrong ??

    Please look at your E-Bill and click report a problem.

  • Question about class design

    Hi:
    I am trying to design a web game using JSP, servlets, etc. I have some ideas about the classes I have to create and how to split the work among them. I.e:
    class Player
    - contains the player data like name, nickname, age, etc...
    - have a static method getPlayerById(id) which calls load(id) method.
    - load method calls DBPlayer.load(id)
    class DBPlayer
    - uses Database objetct to get the connetion.
    - static load(id) method executes a "select" query and gets the data from database and create a new Player instance sending the data by constructor
    class Database
    - get the connetion data and connect to database
    I could have a JSP page named showPlayerInfo.jsp which gets the player_id by request. The page calls Player.getPlayerById(player_id) ans shows the data in html format.
    would this be correct?
    If I would like to show the list of players of a game. Could I have a GamePlayerList servlet which uses Database object, get an array of Player objects which can be shown using a JSP page or the GamePlayerList servlet? should the "retrieving player list data" be in DBPlayer instead?
    Thanks in advance for your advices

    There is no right answer. What you have is a model object (Player) a data access object (DBPlayer, normally this would be named something like PlayerDao) and a utilities class to connect to the database (Database or you could call it DatabaseUtil or DatabaseHelper, whatever) Another option for your Database class is to instead call it AbstractDao, have PlayerDao extend it, and in AbstractDao place methods like connect(), rollback() and commit(). One reason you want these methods in either a helper class or a superclass is so you can place your try-catch blocks there and not have to worry about cluttering up the rest of your code.
    In terms of an overall architecture, you should take a look at the MVC pattern. Your Player and PlayerDao objects are your model. Your servlets are your controllers. And your JSP's are your view. It's a fairly standard way of organizing your application.
    You have several options for how to load new players. The first would be as you have done, to place a static factory method in Player. Another option would be to create a separate PlayerFactory object that can create new or return existing or delete existing players. The Servlet would call the PlayerFactory which would delegate to the PlayerDao returning a Player object. In this design, your Servlet would either invoke the PlayerFactory or PlayerDao to save, etc. If you instead want a bit more encapsulation at the price of separation of concerns, you can have the Player object itself have methods like save(), delete(), etc.
    There is no right answer. Designs involve trade-offs and to a large extent personal (or corporate or academic) preference.
    - Saish

  • A question about creating packages as local objects in ABAP

    Hi,
    I have a question about creating packages with SE80. Whenever I create a new package it is assigned a new transport request. After that, I can create new programs inside this package, and each time I can choose whether to assign the new program to a transport request or just save it as a local object (I often do this for test programs that I don't transport and I remove them once my tests have been done).
    What I would like to ask is that, is it possible to create a package (and not just programs inside a given package) as a local object? so that every new object created in this package will be considered as a local object?
    Thanks in advane,
    Kind Regards,
    Dariyoosh

    Thomas Zloch wrote:
    Please also check the F1 help for the package field e.g. in SE80, SAP standard is in range A-S and U-X, namespaces start with "/", so you should be save. I am using the T namespace for temporary stuff since a long time and did not have a problem so far.
    > Thomas
    >
    > P.S. this applies to the package name only, of course
    Thank you very much for this remark, I checked F1 help for the package field and in fact as you mentioned these ranges are for local objects.
    Once again, thank you very much for your help.
    Kind Regards,
    Dariyoosh

  • A few questions about the design of the scheme

    Hello, all!
    I want ask some question about design of the scheme.
    1) If i store info about user (for example: /Smith/Bob - /phone values{+1 964 258 46 52}), i can request information by user (input parameters: /Smith/Bob - /phone, output:+1 964 258 46 52), but if i want get username by phone i must generate in store second string /19642584652 values{Smith Bob}. But I must duplicate any string - very prodigally. Are existing some work aruond?
    2) if i want store some string with different minor key i put: ( /Smith/Bob - /phone, /Smith/Bob - /image, /Smith/Bob - /adress), but i already get duplicate date. Are existing any compressin major`s key? If yes - how it works
    3) Are existing in Oracle NoSQL something like secondary index? If exist - how it works?
    4) If i want get value by major key, im use get function(for example /Smith/Bob - /phone). How works searching algoritm? What mathematical basis of search?

    >
    So, some a few clarifying questions.
    1) Request comes from the client(to cluster). It identifies the major key. And any rep group understand: contained in it is this line?
    2) If contains - they use b-tree map to find the right key (as local index in Oracle DB).
    Is it correct?
    >
    No. Please read the doc and the other forum threads. They explain this issue.
    >
    Can i use any different algoritm to search, different indexes(function based) for example (on step 2)?
    >
    No.
    when the expected release of this option?Oracle employees cannot talk about future release dates and contents.
    What algorithm used to compress the prefix of the key. And how it work`s.If you're interested in the implementation details you can read the BDB JE documentation on key prefixing and the BDB JE source code. See com.sleepycat.je.DatabaseConfig.setKeyPrefixing.
    http://docs.oracle.com/cd/E17277_02/html/index.html
    --mark                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • How to validate a session object in jsp?

    Hi All,
    i am facing a problem.The problem is how to validate the session object object in jsp.I have written a java script by using a defined function as setInterval and has given 5 mintues if the user is idle and will show a pop up menu before time out the session but in case of page active still this pop up menu is coming. The java script as follows.
    function SetTimer(){
         //How long before timeout (should be a few minutes before your server's timeout
         //set timer to call function to confirm update
         if(timeoutMinutes)
         timerObj = setInterval("ConfirmUpdate()",60000);
    function clearTimerFn(){
              timerCount = 0;
              clearInterval(timerObj);
              //timerObj = setInterval("ConfirmUpdate()",60000);
    function ConfirmUpdate(){
         //Ask them to extend
         if(confirm("Your session is about to expire. Press 'OK' to renew your session.")){
              //load server side page if ok
              var url = "ajaxSessionchecker.do?sessionvalidate=sessionvalid";
              LoadXMLDoc(url);
    And in jsp i am calling this js function as
    <%session=request.getSession(false);
              if(session.getLastAccessedTime()==60000){ %>
              <script type="text/JavaScript">
         clearTimerFn();
    </script>
    <%}else{
    session.setMaxInactiveInterval(-1000);} %>
    could you pls help me out?

    The reason for doing this is when ever i come to this user.jsp from account.jsp with a different account number this user.jsp is not refreshed and i still
    see the same old user.jsp for the previous account that i naviated before. Also please let me know if there is any other approach to acheive this taskDoes refreshing the page by pushing F5 solve the problem?
    If so, then the browser is caching the page, despite your attempts to stop it.

  • How to use session object in jsp

    hi all
    marry christmas
    can anyone plz tell me how to use session obect in jsp
    rachna
    Message was edited by:
    rachna_arora82

    hi rachna,
    JSP has a default(implicit) session object...... use the getSession(true) method on the session object and then going u can either get or set attributes depending on the requirement
    That was in general and now with the issue u have got..... what u can do is that the u can create session for every user who logs in and when he/she tries to login again then u can probably check for the existing session object in the JSP and perform the logic as required..... any clarifications plzzzzzzz let me know
    Thanks n Regards
    Naveen M
    Message was edited by:
    Novice_inJAVA
    Message was edited by:
    Novice_inJAVA

  • URGENT! Share session object in JSP and JServlet

    Dear all,
    I am new to OAS. I am now trying OAS by build a simple Shopping Cart application.
    Currently, I use JSP to build user interface and Servlet to build bussiness logic. So I use JSP cartage and JServlet cartage to build the application.
    However, I find that the "session object" I create in the JSP cannot be access from Servlet cartage.
    Is anyone can help me to solve this problem. ( Is this implementation framework works in OAS ? )

    >
    I am short describing the problem again,
    IN JSP, MY CODE IS LIKE THIS:
    HttpSession oSession=request.getSession(true);
    oSession.setAttribute("batchHash",reqRows);
    IN SERVLET, MY CODE IS LIKE THIS:
    HttpSession oSession=req.getSession(true);
    tblSession = (Hashtable)
    oSession.getAttribute("batchHash");
    System.out.println("IsNew ="+oSession.isNew());
    System.out.println("Object="+prmSSO);
    If I deploy this in TOMCAT, my output is like this:
    IsNew =false
    Object=Hashtable@982fc1
    If I deploy this in WEBLOGIC 6.1, my output is like
    this:
    IsNew =true
    Object=null
    Why is this?
    Why the "oSession.isNew()" returns "false" in tomcat
    and "true" in weblogic ?
    Please help....Your only problem is using
    HttpSession oSession=req.getSession(true);instead of
    HttpSession oSession=req.getSession(false);in your servlet! getSession(true) - forces to allocate new session,
    so it's absolutely clear why your Hashtable is absent in
    a newly created session!!
    Paul

  • Question about Wireless Design and Controller

    Hi Everyone,
    Although I am not new to Cisco, I have somewhat limited experience with Wireless in general.  I was hoping to get your help with the following:
    We currently have a total of 8 1130AG, 4 on each floor.  They were configured a few years ago, and now we are looking to update the design a bit.  Each AP has its own SSID, and just provide internet access.  Looking at the configuration, I noticed that they are not configured to use proper channels, just random channels (9, 10, 11, instead of 1, 6, 11, etc.).  I noticed that when I roam between one AP to another, I lose about 4-8 pings before I re-establish connectivity again.
    Here are my questions:
    1.  Do I need a controller in order to use just one SSID for the whole setup instead of the 8 seprate ones we currently have?
    2.  Will the controller helps in providing seamless transition when a client roams between AP's?
    3.  Is it normal to loose connectivity roaming around?
    4.  Can I reconfigure the current setup to use just one SSID and provide better transition between AP without the use of a controller?
    5.  Which controller would you recommend?
    We don't have a need to anything fancy ,I am aware that I can enable multiple SSID, VLAN's, etc.  Just trying to keep it as simple as possible, yet reliable.
    Your input is appreciate.
    Thanks

    1.  With 8 AP's only, a WLC would be nice-to-have but not necessary. You can configure WLSE and it will do some limited functions.
    2.  This depends on the signal strengths, wireless coverage and configuration.  If you enable WLSE, for instance, and you have no wireless black spots, then roaming should be no issues.
    3.  See #2.
    4.  You can configure multiple SSID (up to 16 are broadcasted) but if one AP doesn't have the SSID you use for roaming, the association will drop when the client tries to join that particular AP.  It's like mobile phone towers.  If your carrier is not in the area, you sure won't be able to use your mobile phone in that area.
    5.  For 8 1130 APs, I'd recommend the smallest of the lot:  2106 with either 6, 12 or 25 AP licenses.  I'd recommend you the 25 AP licenses.  If your finances allow you something bigger, then consider either the 4402 (25 AP licenses) or the 5508.
    Cisco 2100 Series Wireless LAN Controllers
    http://www.cisco.com/en/US/prod/collateral/wireless/ps6302/ps8322/ps7206/ps7221/product_data_sheet0900aecd805aaab9.html
    Cisco 4400 Series Wireless LAN Controllers
    http://www.cisco.com/en/US/prod/collateral/wireless/ps6302/ps8322/ps6307/product_data_sheet0900aecd802570b0_ps6366_Products_Data_Sheet.html
    Cisco 5500 Series Wireless Controllers Data Sheet
    http://www.cisco.com/en/US/prod/collateral/wireless/ps6302/ps8322/ps10315/data_sheet_c78-521631.html

  • Hey guys, I have a question about Web Design

    I have been trying to learn webdesign for a few months now, and so far, I am still learning HTML and some CSS. At the moment, my experience is still very thin, I am struggling with things, and I only know how to create simple, static pages. For example I still don't know how to produce "clean code". Or how one determines just how "clean" the code he has produced really is.
    I was wondering if someone could answer a few questions I have:
    I am still not sure how I will know when I am competent enough to work in Web Design... What are the best signs that an individual is good enough?
    I was also wondering what programming language I need to know to do the following:
    Create a WORKING Site Search. One like the search bar in the top corner of this page that will return search results from your website... Do I need to know how to program PHP? I've heard that you do need PHP to do this? The same goes for creating e-mail forms, and other forms like this. Do I need PHP for this?
    Another thing is CMS systems like Wordpress and Joomla. What is the reason for using these as opposed to just designing a website's pages in Dreamweaver, and then uploading them via FTP to your web server?
    And finally, can someone explain to me why CSS is groped like this when it is coded? Why has the Div ID "OuterWrapper" been styled multiple times?
    For example: #outerWrapper #feature {
    #outerWrapper #subcontentWrapper {
    #outerWrapper #subcontentWrapper #rightColumn {
    ^ Couldnt the designer simply have styled "~OuterWrapper" once and left it at that?
    Please see below:
    #outerWrapper #feature {
        height: 225px;
        width: 880px;
        margin-left: 0px;
        margin-bottom: 5px;
        background-image: url(images/feature.jpg);
        background-repeat: no-repeat;
        background-position: center top;
    #outerWrapper #subcontentWrapper {
        padding-right: 15px;
        padding-left: 15px;
        clear: both;
        padding-top: 20px;
        background-color: #FFF;
        padding-bottom: 40px;
        border-top-width: 4px;
        border-right-width: 4px;
        border-left-width: 4px;
        border-top-style: solid;
        border-right-style: solid;
        border-left-style: solid;
        border-top-color: #F90;
        border-right-color: #F90;
        border-left-color: #F90;
        background-image: url(images/footer-fade.jpg);
        background-repeat: repeat-x;
        background-position: bottom;
        height: 100%;
    #outerWrapper #subcontentWrapper #rightColumn {
        float: right;
        width: 220px;
        background-color: #DBE7FB;
        border: 1px solid #DCDFE4;
        margin-bottom: 15px;
    Also, regarding Javascript: How exactly does one become proficient enough to learn scripting for the thousands of little widgets, and navigation bars, and other functions that Javascript can do out there?
    I know a lot of these questions are strange and may be hard to answer, but I am really hoping some of you guys can provide some helpful advice/direction for me to improve with code. I studied as a Print Graphic Designer, and now it's really hurting me in this economy trying to find a job due to the fact that I lack full competency in Web Design... and the longer it takes me to get better at this, the slimmer my chances become at finding work!
    I really need help on this, so I would be extremely grateful for detailed and informative answers. Perhaps some links to very good video tutorials on learning how to effectively design webpages - Common things like Javascripted navigation bars, image slideshows, how to design working site search forms and contact forms, and how to use Wordpress. I ask this because there are so many terrbile tutorial videos out there (I know from experience) and it is next to impossible for myself, a beginner, to tell the good ones from the bad.
    Thankyou guys.

    CMS's like  WordPress, Joomla! & Drupal are popular open source (PHP & MySql) frameworks.  They contain all the backend PHP code needed to create a dynamic web site that contains capability for advanced functions:  site search, on-line editing, shopping carts, member log-in sites, blogs with comments, scripted contact forms, and so much more...
    The allure of Open Source frameworks is that they save developers time and money.  Instead of building everything from scratch (which can take months), an experienced developer can usually install WordPress on the client's server and be up & running in a few hours without customizations, or in a couple of weeks with customizations.   A firm understanding of PHP, how to set up a server-side database, backing up MySql, CSS theming, and HTML code are required skills to work with these frameworks.  WordPress is probably the easiest to set-up; Drupal is for more experienced coders.
    I am still not sure how I will know when I am competent enough to work in Web Design... What are the best signs that an individual is good enough?
    You're ready when you can look at code and understand what it means/does. Being able to problem solve, identify mistakes and fix them on your own is a must have skill. 
    Code Tutorials - http://w3schools.com/
    How to Develop with CSS?
    http://phrogz.net/css/HowToDevelopWithCSS.html
    CSS positioning in 10 Steps
    http://www.barelyfitz.com/screencast/html-training/css/positioning/
    Code Validation Tools
    CSS - http://jigsaw.w3.org/css-validator/
    HTML - http://validator.w3.org/
    Nancy O.
    Alt-Web Design & Publishing
    Web | Graphics | Print | Media  Specialists 
    http://alt-web.com/
    http://twitter.com/altweb

  • A question about ResultSet.UpdateObject(int column, Object x)

    hi, I write some code which use the TableModel to represent the data fetched from MS-ACCESS.
    the problem is about the UpdateObject(...) method which is in the implement of the AbstractTableModel method setAtValue(). when transfered OBJECT TYPE is java.lang.String, I can't get the correct result in the JTable view.
    my code is as below, could somebody point me out my problem
    public class MyTableModel extends AbstractTableModel {
        private ResultSet rs ;
        private ResultSetMetaData rsmd;
        /** Creates a new instance of MyTableModel */
        public MyTableModel() {
            try {
                Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
            } catch (ClassNotFoundException ex) {
                ex.printStackTrace();
            String url = "jdbc:odbc:CoffeeBreak";
            try {
                Connection con = DriverManager.getConnection(url,"","");
                String strSQL = "SELECT * FROM COFFEES";
                Statement pSt = con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
                rs = pSt.executeQuery(strSQL);
                rsmd = rs.getMetaData();
            } catch (SQLException ex) {
                ex.printStackTrace();
    /* table model retrieve the Class type of a column method here*/
    public Class getColumnClass(int c){
            try {
                return Class.forName(rsmd.getColumnClassName(c+1));
            } catch (ClassNotFoundException ex) {
                ex.printStackTrace();
            } catch (SQLException ex) {
                ex.printStackTrace();
            return String.class;
    //method of update database and JTable after user edited a table cell
    public void setValueAt(Object aValue, int rowIndex, int columnIndex) {
            try {
                int concurrency = rs.getConcurrency();
                if(concurrency == 1008){
                    rs.absolute(rowIndex+1);    //the JTable row index is start from 0,so plus 1
                    rs.updateObject(columnIndex+1, aValue);//the JTable column index is start from 0, so plus 1
                    rs.updateRow();
            } catch (SQLException ex) {
                ex.printStackTrace();
        }when the column type is about java.lang.String, the cell's result is incorrect, it looks like "[B@1f8f72f" and database can't update.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

    It's me again.
    I post the whole class code here
    import java.sql.Connection;
    import java.sql.DriverManager;
    import java.sql.PreparedStatement;
    import java.sql.ResultSet;
    import java.sql.ResultSetMetaData;
    import java.sql.SQLException;
    import java.sql.Statement;
    import javax.swing.event.TableModelEvent;
    import javax.swing.event.TableModelListener;
    import javax.swing.table.AbstractTableModel;
    * @author qhj
    public class MyTableModel extends AbstractTableModel {
        /** Creates a new instance of MyTableModel */
        private ResultSet rs ;
        private ResultSetMetaData rsmd;
        private Statement pSt;
        private String strSQL;
        public MyTableModel() {
            try {
                Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
            } catch (ClassNotFoundException ex) {
                ex.printStackTrace();
            String url = "jdbc:odbc:CoffeeBreak";
            try {
                Connection con = DriverManager.getConnection(url,"","");
                strSQL = "SELECT * FROM COFFEES";
                pSt = con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
                rs = pSt.executeQuery(strSQL);
                rsmd = rs.getMetaData();
            } catch (SQLException ex) {
                ex.printStackTrace();
        public int getRowCount() {
            try {
                rs.last();
                return rs.getRow();
            } catch (SQLException ex) {
                ex.printStackTrace();
            return 0;
        public int getColumnCount() {
            try {
                return rsmd.getColumnCount();
            } catch (SQLException ex) {
                ex.printStackTrace();
            return 0;
        public Object getValueAt(int rowIndex, int columnIndex) {
            try {
                rs.absolute(rowIndex+1);
                return rs.getObject(columnIndex+1);
            } catch (SQLException ex) {
                ex.printStackTrace();
            return null;
        public String getColumnName(int column){
            try {
                return rsmd.getColumnName(column+1);
            } catch (SQLException ex) {
                ex.printStackTrace();
            return "N/A";
        public Class getColumnClass(int c){
            try {
                return Class.forName(rsmd.getColumnClassName(c+1));
            } catch (ClassNotFoundException ex) {
                ex.printStackTrace();
            } catch (SQLException ex) {
                ex.printStackTrace();
            return String.class;
        public boolean isCellEditable(int row, int col) {
            //Note that the data/cell address is constant,
            //no matter where the cell appears onscreen.
            return true;
        public void setValueAt(Object aValue, int rowIndex, int columnIndex) {
            try {
                int concurrency = rs.getConcurrency();
                if(concurrency == 1008){
                    rs.absolute(rowIndex+1);
                    rs.updateObject(columnIndex+1, aValue);
                    //rs.updateRow();
                    //rs = pSt.executeQuery(strSQL);
            } catch (SQLException ex) {
                ex.printStackTrace();
            fireTableDataChanged();
    }

  • Question about OU design

    Our Active Directory implementation consists of a geographic design with branch office OUs that each contain sub OUs for users and computers.
    I am proposing to my team that we consolidate our geographic OU structure because
    Each branch office OU and sub OUs contain exactly the same links to each GPO
    We do not have a need to delegate permissions, nor do we foresee any need to do so in the near term
    Eases AD administration by removing the dependency of our OU structure when we introduce new offices (i.e. do not have to create new OUs, link GPOs, introduce new application configurations, such as SharePoint, System Center, and custom apps, which may
    be OU-dependent)
    Eases AD administration so that we do not have to micromanage which computer and user accounts end up in certain OUs
    My teammate argues against consolidating the geographic OU structure because
    We can keep the existing geographic OU structure and link all GPOs to the root (not to the domain, but to the root OU that is parent to all the branch office OUs), so that sub OUs inherit the GPO settings
    Having a geographic topology simplifies administration because micromanaging where computers accounts and user accounts go makes it easier for admins to find the accounts
    Applications that use AD, such as SCCM, SCSM, and SharePoint, can be configured to do a recursive search from the top of the structure.  So the ease of AD administration in this regard is already inherent.
    What suggestions/advice can you offer?

    Greetings!
    Designing OU structure is completely dependent to the needs and requirements of the organization. Although by having a hierarchy based OU structure you will have a better view of your active directory and administration of computer and user will be eased,
    it may adds complexity to the environment. 
    They are quite right. In my environment they are nearly thousands of objects in Active Directory spreading all over the country. I have a top-level OU representing the country with sub OU's for each province. Also in each of these sub OU's there are other
    sub OU's inside it for computers, users and etc. I know it may add the complexity to the environment, but so far I felt comfortable with these structure.
    In addition some SCCM related tasks will be very easy going when you have these structure. For example discovery process for collections based on sub OU's is very flexible. The same story goes for SCOM and discovering computer objects for creating specific
    groups and dashboards.
    On the other hand, I designed another structure with only one OU and one level of sub OU  for another company because they had no specific services and simply there was no need for this design.
    Regards.
    Mahdi Tehrani   |  
      |  
    www.mahditehrani.ir
    Please click on Propose As Answer or to mark this post as
    and helpful for other people.
    This posting is provided AS-IS with no warranties, and confers no rights.
    How to query members of 'Local Administrators' group in all computers?

  • Question about using threads and synchronizing objects

    Hi all,
    I am not that familiar and I have 2 questions.
    QUESTION 1
    I have a server which just sits and accepts incomming connections, then I spawn off a new thread which implements Runnable, and then call the run method. But the loop would not iterate, it would just sit inside the run method (which has rather long loop in it). I changed the class to extend Thread and called the start() method, rather than run(), and everything worked out fine.
    Anyone know why this is?
    QUESTION 2
    So I am building a client server chat application where a user can be in multiple chat rooms. I have this personObject which has output/input streams. In the personObject, I create writeObject/ readObject method, which simply does as it implies.
    I figured that I should make these methods synchronized, to ensure things run smoothly. however, when I made a call to readObject, which sat there and waited, and then made a call to writeObject, I would not enter the writeObject method. I took out the synchronized on the writeObject, and everything worked out fine.
    I was under the assumption that synchronizing a method only synchronized on that method, not on the whole class. How come then was I not able to enter the writeObject method?
    The more I think about it, I don't think I need to have these methods synchronized, but I thought it wouldn't hurt.
    Thanks for the help.

    Hi all,
    I am not that familiar and I have 2 questions.
    QUESTION 1
    I have a server which just sits and accepts incomming
    connections, then I spawn off a new thread which
    implements Runnable, and then call the run method.
    But the loop would not iterate, it would just sit
    inside the run method (which has rather long loop in
    it). I changed the class to extend Thread and called
    the start() method, rather than run(), and everything
    worked out fine.
    Anyone know why this is?
    You should still implement Runnable, rather than extending Thread. Like this: Runnable r = new MyRunnable();
    Thread t = new Thread(r);
    t.start(); run() is just another method. Nothing special about it as far as multithreading or anything else goes.
    start() is the method that actually spawns a new thread of execution.
    I was under the assumption that synchronizing a
    method only synchronized on that method, not on the
    whole class. How come then was I not able to enter
    the writeObject method?When you synchronize, you obtain a lock. As long as you hold that lock--until you exit the sync block or call wait()--no other thread can enter that block or any other block that obtains the same lock.
    Two synchronized methods on the same object rely on obtaining the same lock--there's one lock for each object.

Maybe you are looking for

  • Novo Cálculo de IPI na MP 540

    Amigos, Não sei dúvidas de localização BR são colocadas aqui mas vamos lá: O governo acaba de editar a Medida Provisória 540 que vai alterar a forma de tributação do cigarro. Como sabemos, a função que calcula impostos na TAXBRJ não nos permite inser

  • XML Publisher/Bi Publisher Using Oracle Package and MS Word Template builde

    My Question is I want to know more about grouping of elements while creating reports in E business suite. my approach should be 1. pl sql package with embedded XML data to create xml output. 2. Formatting the xml output using ms word template builder

  • Can't see whole song title in search

    is there a way to widen the width of the title columns in the itunes store so that you can tell if a song is a remix or not before you buy it? also I don't seem to be able to sort a list that came up for a search by anything other than relevency.

  • Invoking a specfic configuration in integration directory (abap proxy)

    Hello, I have a ABAP inbound and ABAP outbound proxy sitting on  different SAP Backends,both the abap inbound and outbound sit on multiple systems,but the message mapping  and interface mapping is 1. In the integration direction I have multiple confi

  • Main computer is it necessary

    we have just one telephone socket in the house, so for the last few weeks ive had 20 meters of cable running through the house, every time i want to go online. i bought a wireless g router (wrt54gr)and a couple of net cards to get rid of those annoyi