Java object related doubt

Hi All,
I have a doubt. Does the code segment of a java class get repeated in all the objects created from that class ? Or the single code segment is used by all objects created from a single class ?
Regards,
Sourav

No, code is associated with a class, and there is a single copy of a class within a process for each class loader that loads it (usually just one).

Similar Messages

  • Using transaction activation policy together with TOPLINK Java object/relational mapping "commit and resume" transaction?

    Has any one has experience using WLE transaction context together with TOPLINK Java
    version of "commit and resume" context?

    Has any one has experience using WLE transaction context together with TOPLINK Java
    version of "commit and resume" context?

  • Best way for Java objects to relate to DB tables

    When creating a Java app which relies on a backend DB, it is convenient (and necessary) to create Java classes which relate to the data in those tables. However with a normalised set of tables, should the Java classes relate purely to the tables, or the "view" of the un-normalised data?
    e.g. (rough example of what I mean)
    CREATE TABLE teams
    team_id INTEGER NOT NULL PRIMARY KEY,
    team_name CHAR(50)
    CREATE TABLE users
    user_id INTEGER NOT NULL PRIMARY KEY,
    user_name CHAR(50),
    team_id INTEGER REFERENCES teams(team_id)
    Now, the Java class for a user could have either have a variable (e.g. teamName) declared as an int (to fully reflect the table design) or a String (to represent the "view" of the data). I know that views can be used etc. and in this example that would be very easy � I am just using these simplified tables as an example.
    I have tried both and both have pitfalls. For instance, when getting the data from the database, it is very easy to create the object from the DB if it reflects the �view� of the data. However when it comes to updating the data in the DB, you need to do a lot of other work to find out what needs updating in which tables, because the actual raw data (as will be inserted/updated with SQL commands) is not available in the Java object.
    I hope this makes sense.
    Thanks.

    My question is what is the best way to write the classes that represent the DB data. As I said this is not EJB (that would handle the DB side of things anyway), as this is overkill for this particular situation. It was more of a general question anyway - should the class contain the actual data (e.g. should the user Class contain a String for the team name (e.g. Purchasing) or a link to the underlying DB id for Purchasing.
    In reality, I would create a Team class, but the same applies - should the Java Class ever contain any relationship to the underlying DB. I think not, but it seems inefficient to have to continually query the DB to find out information we already have.
    Apologies if I am not explaining this very well.

  • How can I use XStream to persist complicated Java Object  to XML & backward

    Dear Sir:
    I met a problem as demo in my code below when i use XTream to persist my Java Object;
    How can I use XStream to persist complicated Java Object to XML & backward??
    See
    [1] main code
    import java.io.BufferedReader;
    import java.io.BufferedWriter;
    import java.io.FileReader;
    import java.io.FileWriter;
    import java.io.IOException;
    import java.util.ArrayList;
    import com.thoughtworks.xstream.XStream;
    import com.thoughtworks.xstream.io.xml.DomDriver;
    public class PhoneList {
         ArrayList<PhoneNumber> phones;
         ArrayList<Person> person;
         private PhoneList myphonelist ;
         private LocationTest location;
         private PhoneList(String name) {
         phones = new ArrayList<PhoneNumber>();
         person = new ArrayList<Person>();
         public ArrayList<PhoneNumber> getphones() {
              return phones;
         public ArrayList<Person> getperson() {
              return person;
         public void addPhoneNumber(PhoneNumber b1) {
              this.phones.add(b1);
         public void removePhoneNumber(PhoneNumber b1) {
              this.phones.remove(b1);
         public void addPerson(Person p1) {
              this.person.add(p1);
         public void removePerson(Person p1) {
              this.person.remove(p1);
         public void BuildList(){
              location = new LocationTest();
              XStream xstream = new XStream();
              myphonelist = new PhoneList("PhoneList");
              Person joe = new Person("Joe, Wallace");
              joe.setPhone(new PhoneNumber(123, "1234-456"));
              joe.setFax(new PhoneNumber(123, "9999-999"));
              Person geo= new Person("George Nixson");
              geo.setPhone(new PhoneNumber(925, "228-9999"));
              geo.getPhone().setLocationTest(location);          
              myphonelist.addPerson(joe);
              myphonelist.addPerson(geo);
         public PhoneList(){
              XStream xstream = new XStream();
              BuildList();
              saveStringToFile("C:\\temp\\test\\PhoneList.xml",convertToXML(myphonelist));
         public void saveStringToFile(String fileName, String saveString) {
              BufferedWriter bw = null;
              try {
                   bw = new BufferedWriter(
                             new FileWriter(fileName));
                   try {
                        bw.write(saveString);
                   finally {
                        bw.close();
              catch (IOException ex) {
                   ex.printStackTrace();
              //return saved;
         public String getStringFromFile(String fileName) {
              BufferedReader br = null;
              StringBuilder sb = new StringBuilder();
              try {
                   br = new BufferedReader(
                             new FileReader(fileName));
                   try {
                        String s;
                        while ((s = br.readLine()) != null) {
                             // add linefeed (\n) back since stripped by readline()
                             sb.append(s + "\n");
                   finally {
                        br.close();
              catch (Exception ex) {
                   ex.printStackTrace();
              return sb.toString();
         public  String convertToXML(PhoneList phonelist) {
              XStream xstream = new  XStream(new DomDriver());
              xstream.setMode(xstream.ID_REFERENCES) ;
              return xstream.toXML(phonelist);
         public static void main(String[] args) {
              new PhoneList();
    }[2].
    import java.io.Serializable;
    import javax.swing.JFrame;
    public class PhoneNumber implements Serializable{
           private      String      phone;
           private      String      fax;
           private      int      code;
           private      String      number;
           private      String      address;
           private      String      school;
           private      LocationTest      location;
           public PhoneNumber(int i, String str) {
                setCode(i);
                setNumber(str);
                address = "4256, Washington DC, USA";
                school = "Washington State University";
         public Object getPerson() {
              return null;
         public void setPhone(String phone) {
              this.phone = phone;
         public String getPhone() {
              return phone;
         public void setFax(String fax) {
              this.fax = fax;
         public String getFax() {
              return fax;
         public void setCode(int code) {
              this.code = code;
         public int getCode() {
              return code;
         public void setNumber(String number) {
              this.number = number;
         public String getNumber() {
              return number;
         public void setLocationTest(LocationTest bd) {
              this.location = bd;
            JFrame f = new JFrame();
            f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            f.getContentPane().add(location);
            f.getContentPane().add(location.getControls(), "Last");
            f.setSize(400,400);
            f.setLocation(200,200);
            f.setVisible(true);
         public LocationTest getLocationTest() {
              return location;
         }[3].
    package test.temp;
    import java.io.Serializable;
    public class Person implements Serializable{
         private String           fullname;
           @SuppressWarnings("unused")
         private PhoneNumber      phone;
           @SuppressWarnings("unused")
         private PhoneNumber      fax;
         public Person(){
         public Person(String fname){
                fullname=fname;           
         public void setPhone(PhoneNumber phoneNumber) {
              phone = phoneNumber;
         public void setFax(PhoneNumber phoneNumber) {
              fax = phoneNumber;
         public PhoneNumber getPhone() {
              return phone ;
         public PhoneNumber getFax() {
              return fax;
        public String getName() {
            return fullname ;
        public void setName(String name) {
            this.fullname      = name;
        public String toString() {
            return getName();
    }[4]. LocationTest.java
    package test.temp;
    import java.awt.*;
    import java.awt.event.*;
    import java.awt.geom.*;
    import javax.swing.*;
    import javax.swing.event.*;
    public class LocationTest extends JPanel implements ChangeListener
        Ellipse2D.Double ball;
        Line2D.Double    line;
        JSlider          translate;
        double           lastTheta = 0;
        public void stateChanged(ChangeEvent e)
            JSlider slider = (JSlider)e.getSource();
            String name = slider.getName();
            int value = slider.getValue();
            if(name.equals("rotation"))
                tilt(Math.toRadians(value));
            else if(name.equals("translate"))
                moveBall(value);
            repaint();
        protected void paintComponent(Graphics g)
            super.paintComponent(g);
            Graphics2D g2 = (Graphics2D)g;
            g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
                                RenderingHints.VALUE_ANTIALIAS_ON);
            if(ball == null)
                initGeom();
            g2.setPaint(Color.green.darker());
            g2.draw(line);
            g2.setPaint(Color.red);
            g2.fill(ball);
        private void initGeom()
            int w = getWidth();
            int h = getHeight();
            int DIA = 30;
            int padFromEnd = 5;
            line = new Line2D.Double(w/4, h*15/16, w*3/4, h*15/16);
            double x = line.x2 - padFromEnd - DIA;
            double y = line.y2 - DIA;
            ball = new Ellipse2D.Double(x, y, DIA, DIA);
            // update translate slider values
            int max = (int)line.getP1().distance(line.getP2());
            translate.setMaximum(max);
            translate.setValue(max-padFromEnd);
        private void tilt(double theta)
            // rotate line from left end
            Point2D pivot = line.getP1();
            double lineLength = pivot.distance(line.getP2());
            Point2D.Double p2 = new Point2D.Double();
            p2.x = pivot.getX() + lineLength*Math.cos(theta);
            p2.y = pivot.getY() + lineLength*Math.sin(theta);
            line.setLine(pivot, p2);
            // find angle from pivot to ball center relative to line
            // ie, ball center -> pivot -> line end
            double cx = ball.getCenterX();
            double cy = ball.getCenterY();
            double pivotToCenter = pivot.distance(cx, cy);
            // angle of ball to horizon
            double dy = cy - pivot.getY();
            double dx = cx - pivot.getX();
            // relative angle phi = ball_to_horizon - last line_to_horizon
            double phi = Math.atan2(dy, dx) - lastTheta;
            // rotate ball from pivot
            double x = pivot.getX() + pivotToCenter*Math.cos(theta+phi);
            double y = pivot.getY() + pivotToCenter*Math.sin(theta+phi);
            ball.setFrameFromCenter(x, y, x+ball.width/2, y+ball.height/2);
            lastTheta = theta;  // save theta for next time
        private void moveBall(int distance)
            Point2D pivot = line.getP1();
            // ball touches line at distance from pivot
            double contactX = pivot.getX() + distance*Math.cos(lastTheta);
            double contactY = pivot.getY() + distance*Math.sin(lastTheta);
            // find new center location of ball
            // angle lambda = lastTheta - 90 degrees (anti-clockwise)
            double lambda = lastTheta - Math.PI/2;
            double x = contactX + (ball.width/2)*Math.cos(lambda);
            double y = contactY + (ball.height/2)*Math.sin(lambda);
            ball.setFrameFromCenter(x, y, x+ball.width/2, y+ball.height/2);
        JPanel getControls()
            JSlider rotate = getSlider("rotation angle", "rotation", -90, 0, 0, 5, 15);
            translate = getSlider("distance from end",  "translate", 0, 100, 100,25, 50);
            JPanel panel = new JPanel(new GridLayout(0,1));
            panel.add(rotate);
            panel.add(translate);
            return panel;
        private JSlider getSlider(String title, String name, int min, int max,
                                  int value, int minorSpace, int majorSpace)
            JSlider slider = new JSlider(JSlider.HORIZONTAL, min, max, value);
            slider.setBorder(BorderFactory.createTitledBorder(title));
            slider.setName(name);
            slider.setPaintTicks(true);
            slider.setMinorTickSpacing(minorSpace);
            slider.setMajorTickSpacing(majorSpace);
            slider.setPaintLabels(true);
            slider.addChangeListener(this);
            return slider;
    }OK, My questions are:
    [1]. what I generated XML by XSTream is very complicated, especially for object LocationTest, Can we make it as simple as others such as Person object??
    [2]. after I run it, LocationTest will popup and a red ball in a panel will dsiplay, after I change red ball's position, I hope to persist it to xml, then when I read it back, I hope to get same picture, ie, red ball stiil in old position, How to do that??
    Thanks a lot!!

    Positive feedback? Then please take this in a positive way: if you want to work on persisting Java objects into XML, then GUI programming is irrelevant to that goal. The 1,000 lines of code you posted there appeared to me to have a whole lot of GUI code in it. You should produce a smaller (much smaller) example of what you want to do. Calling the working code from your GUI program should come later.

  • Printing out results in case of object-relational table (Oracle)

    I have made a table with this structure:
    CREATE OR REPLACE TYPE Boat AS OBJECT(
    Name varchar2(30),
    Ident number,
    CREATE OR REPLACE TYPE Type_boats AS TABLE OF Boat;
    CREATE TABLE HOUSE(
    Name varchar2(40),
    MB Type_boats)
    NESTED TABLE MB store as P_Boat;
    INSERT INTO House VALUES ('Name',Type_boats(Boat('Boat1', 1)));
    I am using java to print out all the results by calling a procedure.
    CREATE OR REPLACE package House_boats
    PROCEDURE add(everything works here)
    PROCEDURE results_view;
    END House_boats;
    CREATE OR REPLACE Package.body House_boats AS
    PROCEDURE add(everything works here) AS LANGUAGE JAVA
    Name House_boats.add(...)
    PROCEDURE results_view AS LANGUAGE JAVA
    Name House_boats.resuts_view();
    END House_boats;
    However, I am not able to get Results.view working in case of object-relation table. This is how I do it in the situation of relational table.
    CALL House_boats.results_view();
    House_boats.java file which is loaded using LOADJAVA:
    import java.sql.*;
    import java io.*;
    public class House_boats {
    public static void results_view ()
       throws SQLException
       { String sql =
       "SELECT * from House";
       try { Connection conn = DriverManager.getConnection
    ("jdbc:default:connection:");
       PreparedStatement pstmt = conn.prepareStatement(sql);
       ResultSet rset = pstmt.executeQuery();
      printResults(rset);
      rset.close();
      pstmt.close();
       catch (SQLException e) {System.err.println(e.getMessage());
    static void printResults (ResultSet rset)
       throws SQLException { String buffer = "";
       try { ResultSetMetaData meta = rset.getMetaData();
       int cols = meta.getColumnCount(), rows = 0;
       for (int i = 1; i <= cols; i++)
       int size = meta.getPrecision(i);
       String label = meta.getColumnLabel(i);
       if (label.length() > size) size = label.length();
       while (label.length() < size) label += " ";
      buffer = buffer + label + " "; }
      buffer = buffer + "\n";
       while (rset.next()) {
      rows++;
       for (int i = 1; i <= cols; i++) {
       int size = meta.getPrecision(i);
       String label = meta.getColumnLabel(i);
       String value = rset.getString(i);
       if (label.length() > size) size = label.length();
       while (value.length() < size) value += " ";
      buffer = buffer + value + " ";  }
      buffer = buffer + "\n";   }
       if (rows == 0) buffer = "No data found!\n";
       System.out.println(buffer); }
       catch (SQLException e) {System.err.println(e.getMessage());}  }
    How do I print out the results correctly in my case of situation?
    Thank you in advance

    I have made a table with this structure:
    I am using java to print out all the results by calling a procedure.
    However, I am not able to get Results.view working in case of object-relation table. This is how I do it in the situation of relational table.
    How do I print out the results correctly in my case of situation?
    There are several things wrong with your code and methodology
    1. The code you posted won't even compile because there are several syntax issues.
    2. You are trying to use/test Java in the database BEFORE you get the code working outside the DB
    3. Your code is not using collections in JDBC properly
    I suggest that you use a different, proven approach to developing Java code for use in the DB
    1. Use SIMPLE examples and then build on them. In this case that means don't add collections to the example until ALL other aspects of the app work properly.
    2. Create and test the Java code OUTSIDE of the database. It is MUCH easier to work outside the database and there are many more tools to help you (e.g. NetBeans, debuggers, DBMS_OUTPUT windows, etc). Trying to debug Java code after you have already loaded it into the DB is too difficult. I'm not aware of anyone, even at the expert level, that develops that way.
    3. When using complex functionality like collections first read the Oracle documentation (JDBC Developer Guide and Java Developer's Guide). Those docs have examples that are known to work.
    http://docs.oracle.com/cd/B28359_01/java.111/b31225/chfive.htm
    http://docs.oracle.com/cd/E11882_01/java.112/e16548/oraarr.htm#sthref583
    The main issue with your example is #3 above; you are not using collections properly:
    String value = rset.getString(i);
    A collection is NOT a string so why would you expect that to work for a nested table?
    A collection needs to be treated like a collection. You can even treat the collection as a separate result set. Create your code outside the database and use the debugger in NetBeans (or other) on this replacement code for your 'printResults' method:
    static void printResults (ResultSet rset) throws SQLException {
        try {
           ResultSetMetaData meta = rset.getMetaData();
           while (rset.next()) {
               ResultSet rs = rset.getArray(2).getResultSet();
               rs.next();
               String ndx = rs.getString(1);
               Struct struct = (Struct) rs.getObject(2);
               System.out.println(struct.getSQLTypeName());
               Object [] oa = struct.getAttributes();
               for (int j = 0; j < oa.length; j++) {
                  System.out.println(oa[j]);
        } catch  (SQLException e) {
           System.err.println(e.getMessage());
    That code ONLY deals with column 2 which is the nested table. It gets that collection as a new resultset ('rs'). Then it gets the contents of that nested table as an array of objects and prints out the attributes of those objects so you can see them.
    Step through the above code in a debugger so you can SEE what is happening. NetBeans also lets you enter expressions such as 'rs' in an evaluation window so you can dynamically try the different methods to see what they do for you.
    Until you get you code working outside the database don't even bother trying to load it into the DB and create a Java stored procedure.
    Since your current issue has nothing to do with this forum I suggest that you mark this thread ANSWERED and repost it in the JDBC forum if you need further help with this issue.
    https://forums.oracle.com/community/developer/english/java/database_connectivity
    When you repost you can include a link to this current thread if you want. Once your Java code is actually working then try the Java Stored procedure examples in the Java Developer's Guide doc linked above.
    At the point you have any issues that relate to Java stored procedures then you should post them in the SQL and PL/SQL forum
    https://forums.oracle.com/community/developer/english/oracle_database/sql_and_pl_sql

  • Need help in Object-Relational Mapping

    I'm writing a simple two-tiered business application with Swing application on the client side and a DBMS on the server side. To make my client code more maintainable, I decided to create Business Objects instead of having my client accessing the database directly via SQL. For simplicity, I'm not using any features from the J2EE framework, and the Business Objects will be hosted on the client side, with one-to-one mapping to tables in the database. Since this is my first attempt in Object-Relational Mapping, I'm faced with the following problems:
    1. What kind of methods are appropriate for business objects? For example, if I have a Machine and Employee entity. A Machine is owned by an employee, and this is represented in the DB by storing the employee ID (not the name) as a foreign key in the Machine table. Let's say in the user interface I have a table that needs to display the list of Machines, but instead of displaying the owner employee's ID, I want to display the owner employee's name by doing a join select. Should the findMachines() method always perform a join select to get owner's name and store it in the Machine object which is returned, or should findMachines() simply return the owner's ID so the UI will need to make another SQL call (through the Employee object) to get the employee's name? The latter is more elegant, but would it be horribly inefficient if there are lots of machines to be displayed (and for each machine we make a separate select call to get the owner's name).

    Business objects should be separate from how they're persisted.
    When you say object-relational mapping, do you mean a tool like Hibernate? Or are you writing your own persistence layer using JDBC and SQL?
    I'd recommend that you read about the Data Access Object pattern and keep the persistence code out of the business objects themselves:
    http://java.sun.com/blueprints/corej2eepatterns/Patterns/DataAccessObject.html
    url=http://www-106.ibm.com/developerworks/java/library/j-dao/

  • How to store a Non Serializable Java Object ?

    Hi..
    I have a non serializable java object which I want to store in the Oracle database and retrieve it. Can anyone help me with how to go about doing this ?
    many thanks in advance
    Ragavan

    If you share the same JVM then its possible, but I doubt that is the case. If you don't share the JVM then its
    impossible to share an object between two apps.
    But if all your attempting to do is duplicate the object in the other app then I spose it is possible, as long as
    you can reconstruct the object from information that you can interegate from the object.
    For example, if you have App A, and App B. WIthin App A is a Double d object. Then you could get the
    value of the Double by doing:
    d.doubleValue()
    write the double to a file/socket/stream, read the file/socket/stream at the other end, create a new Double
    via Double d = new Double(parsedValue);
    Now the two Apps will have a Double d object that represent the same value via a a.equals(b) == true, but
    they will not refer to the same object within memory/jvm.
    James.

  • Tool to create Java Object classes using the Database Tables

    Hi,
    Is their any tools or utility available to create the Java Object Classes using the Database Tables as input.
    Lets Say I am having the Employee, Employee_Salary tables in the Database.The utility has to create the Java Object classes with the relation.
    Please Help...
    Thx..

    Hm, for generating regular Java classes I wouldn't know one from memory. But I suggest you start searching in for example the Eclipse marketspace for a third party plugin that can do it. If all fail, you could always use Hibernate Tools from the Jboss Tools Eclipse plugin set to generate Hibernate/JPA entities and then strip the annotations from them to turn them into regular POJO classes.
    How many tables are we talking about anyway? It might be less effort to just create the classes with properties and then use an IDE to generate getters and setters for them.

  • Using java objects in coldfusion

    I have a java object, that needs to be used in a cfm page.
    The java object itself references classes from an external jar
    file. I've copied the java object class, and the external jar files
    in the web-inf/lib directory of coldfusion.
    My java object is:
    import org.apache.commons.httpclient.*;
    import org.apache.commons.httpclient.methods.*;
    import org.apache.commons.httpclient.params.HttpMethodParams;
    public class TestObj{
    public TestObj() {
    // TODO Auto-generated constructor stub
    public boolean Connect(String url)
    boolean connected=true;
    HttpClient client = new HttpClient();
    GetMethod method = new GetMethod(url);
    method.getParams().setParameter(HttpMethodParams.RETRY_HANDLER,
    new DefaultHttpMethodRetryHandler(0, false));
    try {
    // Execute the method.
    int statusCode = client.executeMethod(method);
    if (statusCode != HttpStatus.SC_OK) {
    connected=false;
    connected=true;
    } catch (Exception e) {
    connected=false;
    } finally {
    // Release the connection.
    method.releaseConnection();
    return(connected);
    I'm accessing the object in the following way within the cfm:
    <cfobject action="create" type="Java" class="TestObj"
    name="tobj">
    <cfset connctd=tobj.Connect("
    http://some url...")>
    I get an error '500 null' when I load this cfm. When I
    comment out the code for httpclient and related objects in TestObj
    and reload the page, I don't see an error. This makes me think that
    httpclient is not accessible to the java object in the coldfusion
    environment even though I've copied the related jar files for
    httpclient and the other objects in the web-inf/lib directory.
    So my question is: Can a java object, being called from a
    coldfusion page, reference other java objects available in jar
    files in a coldfusion environment?
    Any help on this is greatly appreciated.
    Thanks

    Yes, my test class is in a jar.
    Here's the error I'm seeing in exception.log:
    "Error","jrpp-2"...
    java.lang.NoClassDefFoundError
    at TestObj.Connect(Unknown Source)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native
    Method)
    at
    sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at
    sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:324)
    at
    coldfusion.runtime.java.JavaProxy.invoke(JavaProxy.java:74)
    at coldfusion.runtime.CfJspPage._invoke(CfJspPage.java:1634)
    at
    cfplayer2ecfm1189192416._factor6(C:\Webserver\player\player.cfm:157)
    at
    cfplayer2ecfm1189192416.runPage(C:\Webserver\player\player.cfm:1)
    at coldfusion.runtime.CfJspPage.invoke(CfJspPage.java:152)
    at
    coldfusion.tagext.lang.IncludeTag.doStartTag(IncludeTag.java:349)
    at
    coldfusion.filter.CfincludeFilter.invoke(CfincludeFilter.java:65)
    at
    coldfusion.filter.ApplicationFilter.invoke(ApplicationFilter.java:225)
    at
    coldfusion.filter.RequestMonitorFilter.invoke(RequestMonitorFilter.java:51)
    at coldfusion.filter.PathFilter.invoke(PathFilter.java:86)
    at
    coldfusion.filter.LicenseFilter.invoke(LicenseFilter.java:27)
    at
    coldfusion.filter.ExceptionFilter.invoke(ExceptionFilter.java:69)
    at
    coldfusion.filter.BrowserDebugFilter.invoke(BrowserDebugFilter.java:52)
    at
    coldfusion.filter.ClientScopePersistenceFilter.invoke(ClientScopePersistenceFilter.java:2 8)
    at
    coldfusion.filter.BrowserFilter.invoke(BrowserFilter.java:38)
    at
    coldfusion.filter.GlobalsFilter.invoke(GlobalsFilter.java:38)
    at
    coldfusion.filter.DatasourceFilter.invoke(DatasourceFilter.java:22)
    at
    coldfusion.filter.RequestThrottleFilter.invoke(RequestThrottleFilter.java:115)
    at coldfusion.CfmServlet.service(CfmServlet.java:107)
    at
    coldfusion.bootstrap.BootstrapServlet.service(BootstrapServlet.java:78)
    at
    jrun.servlet.ServletInvoker.invoke(ServletInvoker.java:91)
    at
    jrun.servlet.JRunInvokerChain.invokeNext(JRunInvokerChain.java:42)
    at
    jrun.servlet.JRunRequestDispatcher.invoke(JRunRequestDispatcher.java:257)
    at
    jrun.servlet.ServletEngineService.dispatch(ServletEngineService.java:541)
    at
    jrun.servlet.jrpp.JRunProxyService.invokeRunnable(JRunProxyService.java:204)
    at
    jrunx.scheduler.ThreadPool$DownstreamMetrics.invokeRunnable(ThreadPool.java:318)
    at
    jrunx.scheduler.ThreadPool$ThreadThrottle.invokeRunnable(ThreadPool.java:426)
    at
    jrunx.scheduler.ThreadPool$UpstreamMetrics.invokeRunnable(ThreadPool.java:264)
    at jrunx.scheduler.WorkerThread.run(WorkerThread.java:66)
    ---------------------

  • Benefits of object-relational

    Hi,
    I am having a problem with the object-relational features and JDBC.
    It seems that when I select objects from the database into my Java program, those objects can't be used after the Connection is returned to the pool.
    I want to read a bunch of objects from the database and cache them in my program. When I use those objects later, I reference their attributes using the accessor methods. If I have returned the Connection to the pool, I get a "Logical handle no longer valid" error.
    I'm using Oracle 9.0.1, getting a Connection from a OracleConnectionCacheImpl. I am using JPublisher to generate my Java classes, telling it to use the ORAData interface.
    The object features of Oracle looked really nice -- database objects are nicely materialized as Java objects in my program. But what good does it do to have all this fancy generated code if I need to create my own objects from the retrieved objects if I want to use them later?
    Am I missing something? Any comments or pointers?
    Here is the relevant portion of the code.
    try {
    DataSource ds = (DataSource)JndiClient.getConnectionPoolDataSource(poolAlias, "test1", "test1");
    conn = (OracleConnection)ds.getConnection();
    Statement stmt = conn.createStatement();
    rset = (OracleResultSet)stmt.executeQuery("SELECT VALUE(p) FROM process_types p");
    if (rset.next()) {
    np = (NapProcessType)rset.getORAData(1, NapProcessType.getORADataFactory());
    catch (Exception e) {
    System.err.println("Exception: " + e);
    e.printStackTrace();
    finally {
    // Free up resources.
    try {
    if (cs != null)
    cs.close();
    if (rset != null)
    rset.close();
    if (conn != null)
    conn.close();
    catch (SQLException ignore) {
    try {
    System.out.println("getPtName: " + np.getPtName()); // causes Exception
    catch (Exception e) {
    System.err.println("Exception: " + e);
    e.printStackTrace();
    Thanks.
    Mark

    Peter,
    Glad to see you took my advice and posted your question over here. Although I am a frequent user of the Oracle usenet groups, I have found that this is a much better place to get help with Spatial. My experiences suggest that the population of people using spatial is small--and of them the ones that really know alot are few and far between. I can only claim to be in the former group.
    As far as your problem goes--this is probably something you've already considered--is there a way to model the data such that you don't have to replicate the geometry components? Another option would be to handle the replication without using snapshots. Examples would be to export the data and then ftp/copy it to the target machines and import it. If you need real-time replication you could experiment with triggers that execute INSERTs/UPDATEs/DELETEs on the remote databases. This of course has its own issues--but you're going to end up with some sort of compromise no matter how you slice this.
    Of course you could use the relational model. I have never used it so I'm hard pressed to give any advice on it. As I posted on the usenet board, it is heading for desupport in 9i Release 2 according to the documentation available. So if you go relational you'll eventually have to migrate to object/relational. I'm not sure how automatic (or non-automatic) that process is. Hopefully someone on here will have some more concrete advice on that.
    Good luck.
    Matt.

  • Java object reference index..

    Hi All,
    I have two doubts, it will be great if I could be suggested any thing on these.
    1. Is it a good idea to create an java object in the memory, may be 1-2 Mb in size and keep it in the server for a long period? The reason is the server restart may be once in 50-60 days.
    2. If the component objects(child objects... you can think of the whole object as a XML file structure), of the above mentioned object, are having a unique attribute id (type String), can I genereate an index on this attribute that will give me the reference of the object, so that I do not have to traverse the entire object to get an child object having a unique id.
    Can you suggest any algorithm (number of child objects / items in the index will be 80000 - 100000) like binary indexing or hash function etc..
    where in I will search the index with an unique ID (String type) and get a Object reference.
    TIA
    Ayusman

    1. Is it a good idea to ...Based on the information you gave, it is impossible to access whether it is a good idea or bad idea. If your computer has infinite CPU and infinite memory, then it wouldn't matter if you kept 1-2 MB in memory. It comes down to 1) how much time would it take to load that information from disk 2) how much time is the end user / process that depends on the information willing to wait 3) what other resources would be competing for that memory 4) how often would that memory be accessed, in other words, what is the gain / loss of not having it in memory vs the gain / loss of having it in memory.
    2. If the component objects(child objects... A hashtable would provide one possible solution. If your tree structure is likely to grow into 10s or 100s of MBs, then you may want to use a database. XML in my opinion is more of a transitional state of storing information (e.g. when the information needs to be transfered). I don't think storing a XML tree in memory is a good idea because it may not lend well to writing code to gather information.

  • Un-serializing java objects.

    Hi,
    I have a serialized java object.How can I convert it to a normal object or string object?
    Thanks
    Vivek

    Hi,
    I am not writing object into a file.I am
    just creating a objectoutputstream object.I have to
    convert it to string which i guess can be done using
    objectInputstream object .So is there any way out?
    Thanks
    vivekI'm confused by what you are trying to accomplish. An ObjectOutputStream is intended to write objects to a file. You can't convert an ObjectOutputStream to a String, they aren't related. Are you trying to write the objects to a String? I don't see the point of that.

  • Writing a java Object?

    I am first time to write a java object,and i found it is difficult to understand some syntax, can anyone give me some suggestion?

    My steps as a beginning Java programmer involves the following:
    1. Get a simple beginner book on Object Oriented concepts.
    The SUN site has a Tutorial.
    2. Get a good Java Language book. The Sun Site Tutorial has
    similar. Read as much of it as you can take. Then stop.
    3. Install Java standard edition compiler. Free from SUN site.
    Be able to do "javac xxxx.class" <--- compiling, and
    "java xxxx " <-- running xxxx.
    4. Compile and run a few of the examples in the books, and
    Tutorial.
    5. Give yourself a few simple "Program or project" to write,
    ex. "Hello World". Right now I am giving myself a simple
    problem. Finding word from a string. Or a simple word
    parser. Try to write that.
    6. Post your questions in the Beginner Forum (Here). Try
    out the responses from the more experienced repliers.
    7. Got back to the book, and check the section relating
    to the response, and your errors. This 2nd round of
    checking and reading, helps the Concept and understanding
    JAVA.
    8. Keep doing this day after day. You'll see that, as it turns out,
    JAVA does make sense.
    -- gte99te

  • 2 TopLink Java Object from Table to be used in single selectOneChoice

    Hello everyone, can I ask for help on how to solve my problem....
    Here's my scenario, I have 2 tables namely tblCollege and tblCourse, they are related through tblCourse.CollegeCode = tblCollege.Code.
    I use the jdeveloper wizard using TopLink -> Java Object from Table to add these table to my project. I created an EJB Data Control so that I can use them to my Userinterface using ADF Faces.
    What I really want to do is that I need to have selectOneChoice component displaying:
    tblCollege.Name + tblCourse.Name, and it should have a value of tblCollege.Code + tblCourse.Code,
    so for example in my
    tblCollege:
    Code---------Name
    1---------------Science
    2---------------Music
    tblCourse
    Code-------Name-----------CollegeCode
    1-------------Biology----------1
    2-------------Computer-------1
    3-------------Guitar------------2
    what I want in my selectOneChoice is like this:
    value----------display
    1-1--------------Science-Biology
    1-2--------------Science-Computer
    2-3--------------Music-Guitar
    I'm a little stuck on how I'm going to that. Thanks.

    Bawasi,
    I see a couple of angles of attack, but this really depends on the technologies involved. If you are using ADF Bindings in combination with ADF Faces then you need to shape the data at the entity level. If ADF Bindings are no the in equation, you can take a less aggressive approach and shape the data in a managed bean. What is not clear to me is the end-to-end use-case. I see the read-only (i.e. how to get data to the drop box), but I am
    not certain what attribute on an entity you are attempting to set. Are you trying to set the course for the current user or for a master schedule? Finally, notice that the final shape of your data set shows a unique combinations, you could increase the performance of your use-case and ease of development simply by denormalizing your schema.
    --RiC                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • Java Object Cache

    With a cache loader, the Java Object Cache automatically determines if an object needs to be loaded into the cache when the object is request.
    Can someone tellme how exactly this works.
    I am trying to get the cache framework to load objects automatically in the cache.
    hwoever unless i explicitly use the CacheAcess.put method. the object is not loaded in the cache.
    Plss lemme knw, how the framework does it automatically.
    Regards,
    Mukta

    Hi Mukta,
    FYI, This discussion forum is all about Web Cache, and not related to Java Object Cache.
    Anyways, to hint you on automatic loading of objects -> use the CacheAccess.preLoad() method.
    You can post this question in a forum related to the Java Object Cache, for better answers.
    Regards,
    Priyanka GES
    Oracle Web Cache Team

Maybe you are looking for