Strange transaction behaviour on WLS conn pool
I am using BEA WLS 8 anyway
What I have done:
1. I developed EAR and deployed it on BEA WLS.
2. I made conn pool and corresponding Data Source.
What I am doing:
1. I am using select ... for update nowait statement for row locking
The issue:
1. user-1 as operator login to app and select 1 record (select ... for update nowait) which supposed to lock particular selected row.
2. user-2 as supervisor login to app and select the same record (select ... for update nowait) via different menu of course.
3. And the error is not showing. I am expecting resource busy error due to row locking
My investigation:
1. When user-1 locks particular row. I could see the lock session still holding the row.
2. When user-2 do whatever it does esp on committing a transaction, the locking that belongs to user-1 get lost.
3. When user-2 is not committing any transaction but gets logout from app, the locking that belongs to user-1 get lost too.
My suspect:
1. Kind of shared transaction session or something.
How to solve this issue?
Is there something to do with conn pool settings on BEA WLS?
Regards
Eric
Hi Joe,
I have done your instructions and this is the report.
I used BEA's Oracle Driver (Type 4) Versions:8.1.7.9.0.1.9.2.0
URL: jdbc:bea:oracle://ip_address:my_port;spyAttributes=(log=(file)spy.log;timestamp=yes;logTName=yes)
Driver Classname: weblogic.jdbc.oracle.OracleDriver
For extra information (perhaps could help) this is my connection pooling settings:
initial capacity 1
maximum capacity 15
capacity increment 1
statement cache type LRU
statement cache size 10
Login Delay: 0 seconds
Seconds to trust an idle pool connection: 0 seconds
Remove Infected Connections Enabled: true
Allow Shrinking: true
Shrink Frequency: 900 seconds
Enable Connection Leak Profiling: false
Enable Connection Profiling: false
Test Frequency: 0 seconds
Test Reserved Connections: false
Test Created Connections: false
Connection Reserve Timeout: 10 seconds
Connection Creation Retry Frequency: 0 seconds
Inactive Connection Timeout: 0 seconds
Maximum Waiting for Connection: 2147483647
Maximum Connections Made Unavailable: 0
Test Table Name: SQL SELECT 1 FROM DUAL
Init SQL: blank here
And here is my Data Source settings:
Row Prefetch Enabled: false
Row Prefetch Size: 48
Stream Chunk Size: 256 bytes
Honor Global Transactions: true
Emulate Two-Phase Commit for non-XA Driver: false
And this is the spy.log
spy(ExecuteThread: '0' for queue: 'weblogic.admin.HTTP')(2008/07/08 11:35:35.997)>> Connection[1].getMetaData()
spy(ExecuteThread: '0' for queue: 'weblogic.admin.HTTP')(2008/07/08 11:35:35.013)>> OK (DatabaseMetaData[1])
spy(ExecuteThread: '0' for queue: 'weblogic.admin.HTTP')(2008/07/08 11:35:35.013)>> DatabaseMetaData[1].getDatabaseProductName()
spy(ExecuteThread: '0' for queue: 'weblogic.admin.HTTP')(2008/07/08 11:35:35.013)>> OK (Oracle)
spy(ExecuteThread: '0' for queue: 'weblogic.admin.HTTP')(2008/07/08 11:35:35.013)>> DatabaseMetaData[1].getDatabaseProductVersion()
spy(ExecuteThread: '0' for queue: 'weblogic.admin.HTTP')(2008/07/08 11:35:35.013)>> OK (10.2.0.2.0)
spy(ExecuteThread: '0' for queue: 'weblogic.admin.HTTP')(2008/07/08 11:35:35.013)>> Connection[1].close()
spy(ExecuteThread: '0' for queue: 'weblogic.admin.HTTP')(2008/07/08 11:35:35.013)>> OK
spy(ExecuteThread: '0' for queue: 'weblogic.admin.HTTP')(2008/07/08 11:35:39.482)>> Connection[2].getTransactionIsolation()
spy(ExecuteThread: '0' for queue: 'weblogic.admin.HTTP')(2008/07/08 11:35:39.482)>> OK (2)
spy(ExecuteThread: '0' for queue: 'weblogic.admin.HTTP')(2008/07/08 11:35:39.497)>> Connection[2].prepareStatement(String sql)
spy(ExecuteThread: '0' for queue: 'weblogic.admin.HTTP')(2008/07/08 11:35:39.497)>> sql = SELECT 1 FROM DUAL
spy(ExecuteThread: '0' for queue: 'weblogic.admin.HTTP')(2008/07/08 11:35:39.528)>> OK (PreparedStatement[1])
spy(ExecuteThread: '0' for queue: 'weblogic.admin.HTTP')(2008/07/08 11:35:39.528)>> PreparedStatement[1].execute()
spy(ExecuteThread: '0' for queue: 'weblogic.admin.HTTP')(2008/07/08 11:35:39.544)>> OK (true)
spy(ExecuteThread: '0' for queue: 'weblogic.admin.HTTP')(2008/07/08 11:35:39.544)>> PreparedStatement[1].getResultSet()
spy(ExecuteThread: '0' for queue: 'weblogic.admin.HTTP')(2008/07/08 11:35:39.544)>> OK (ResultSet[1])
spy(ExecuteThread: '0' for queue: 'weblogic.admin.HTTP')(2008/07/08 11:35:39.544)>> ResultSet[1].close()
spy(ExecuteThread: '0' for queue: 'weblogic.admin.HTTP')(2008/07/08 11:35:39.544)>> OK
spy(ExecuteThread: '2' for queue: 'weblogic.admin.RMI')(2008/07/08 11:48:23.653)>> Connection[2].rollback()
spy(ExecuteThread: '2' for queue: 'weblogic.admin.RMI')(2008/07/08 11:48:23.653)>> OK
spy(ExecuteThread: '2' for queue: 'weblogic.admin.RMI')(2008/07/08 11:48:23.653)>> Connection[2].close()
spy(ExecuteThread: '2' for queue: 'weblogic.admin.RMI')(2008/07/08 11:48:23.669)>> OK
Hope this adequate to find out the problems.
Regards
Similar Messages
-
Strange MDB behaviour: All MDBs in pool consuming a single message.
Greetings,
I'm noticing rather bizzarre behaviour with an MDB. The MDB in question does nothing
more than consume a message, to a tiny bit of processing, and sends to another JMS
queue.
I set the max pool size to 2, initial pool size to 2. I then put a single JMS message
onto the queue that the MDB is bound to. This is where the problem starts. Both
MDBs in the pool consume the said message (and I end up with two messages in my outbound
queue). I have confirmed that indeed only one message is placed on the queue the
MDBs are bound to. If I set the pool sizes to larger values, all the MDBs in the
pool still end up consuming that one message.
Any ideas?
-Matt.
P.S. Crossposting to .ejb.ejb20I'm not sure what the problem can be, but check that:
1- you're really using a queue and not a topic.
2- your transaction didn't roll back. Catch any throwables in onMessage() to
make sure.
Does this fix it?
Emmanuel
"Matthew" <[email protected]> wrote in message
news:3cd7fb5c$[email protected]..
>
Greetings,
I'm noticing rather bizzarre behaviour with an MDB. The MDB in questiondoes nothing
more than consume a message, to a tiny bit of processing, and sends toanother JMS
queue.
I set the max pool size to 2, initial pool size to 2. I then put a singleJMS message
onto the queue that the MDB is bound to. This is where the problemstarts. Both
MDBs in the pool consume the said message (and I end up with two messagesin my outbound
queue). I have confirmed that indeed only one message is placed on thequeue the
MDBs are bound to. If I set the pool sizes to larger values, all the MDBsin the
pool still end up consuming that one message.
Any ideas?
-Matt.
P.S. Crossposting to .ejb.ejb20 -
Hi all,
I think I have found a bug in EJB transaction.
Here's my setup.
Server: WLS 8.1
JDBCTxDataSource is used with Oracle XA thin JDBC Driver.
JMS XA Connection Factory is set to Enabled.
I have 2 methods in my Stateless Session bean(Container managed
Transaction):
updateDBRecord() and sendMessage().
TX attribute for updateDBRecordis is set to "Required" and sendMessage
is set to "Not Supported".
Here's the usage of these methods:
sendMessage() {
//send a JMS Message using XA enabled connection factory.
throw new EJBException(); // to force an exception
updateDBRecord() {
// get connection from JDBCTxDataSource
// update a record
sendMessage(); // call send message to send a message
I have a client program that makes a call to updateDBRecord(). The
client program catches the EJBException so no DB update is performed.
However, JMS message is not being sent either as if it participated in
the transaction(even though the TX Attribute is set to "Not
Supported"). However, if I use
weblogic.transaction.TxHelper.getTransactionManager().forceSuspend()
and resume() in between my JMS call, then the message will get sent.
The reason I don't want sendMessage() to participate in a transaction
is for performance reason. I don't want 2PC if i can avoid it.
Any help on this is much appreciated.
Regards,
VincentVincent,
The way you do it via a direct Java call you are not using Weblogic's
invocation wrapper that would handle transaction attributes for the methods.
If you want to achieve this you should do it like this:
updateDBRecord()
((MySessionBeanInterface)sessionContext.getEJBObject()).sendMessage();
--dejan
Vincent wrote:
Hi all,
I think I have found a bug in EJB transaction.
Here's my setup.
Server: WLS 8.1
JDBCTxDataSource is used with Oracle XA thin JDBC Driver.
JMS XA Connection Factory is set to Enabled.
I have 2 methods in my Stateless Session bean(Container managed
Transaction):
updateDBRecord() and sendMessage().
TX attribute for updateDBRecordis is set to "Required" and sendMessage
is set to "Not Supported".
Here's the usage of these methods:
sendMessage() {
//send a JMS Message using XA enabled connection factory.
throw new EJBException(); // to force an exception
updateDBRecord() {
// get connection from JDBCTxDataSource
// update a record
sendMessage(); // call send message to send a message
I have a client program that makes a call to updateDBRecord(). The
client program catches the EJBException so no DB update is performed.
However, JMS message is not being sent either as if it participated in
the transaction(even though the TX Attribute is set to "Not
Supported"). However, if I use
weblogic.transaction.TxHelper.getTransactionManager().forceSuspend()
and resume() in between my JMS call, then the message will get sent.
The reason I don't want sendMessage() to participate in a transaction
is for performance reason. I don't want 2PC if i can avoid it.
Any help on this is much appreciated.
Regards,
Vincent -
Hi,
I'm currently facing a very strange Oracle behaviour. First of all, here are the settings:
* 2 CPUs @ 1,6 GHz
* Raid-0 with 2 x 160 GB
* 3 GB RAM
* Windows 2000 Advanced Server
* Oracle Standard 9.2.0.7 using standard settings for the instance
On the machine there is only one db (containing one instance) running, nothing else (beside the OS). The instance has 1GB shared memory assigned and contains about 5 GB of data distributed in approx. 750 tables.
I'm trying to delete all non-master data from the instance via simple "delete <table> where id in (select id from some_table)" statements in a script. This works perfectly (approx. 2-3 million deleted records per hour), processor load is about 50%, the Windows system monitor shows few hundred kilobytes of data read/written per minute.
But this changes after maybe one hour running time. CPU load sinks to 4-5% and data transfer rate rises to approx. 2GB(!!) per minute. I tried to abort the deleting process and rebuild all indexes as well statistics of the schema affected, but without any improvements. The only thing working at the moment is commiting the transaction and shutting down/restarting the instance. Afterwards everything is working fine (without index/statistic rebuilding!), but only for the time period mentioned before.
Does anyone know what could be the source of this behaviour? Anyone got any hints what to change for a better performance? I already thought of bulk inserting the whole schema in a cloned schema without constraints, but 700 tables contain a lot of constraints and triggers, so a consistent insert would be a pain in the tush...
Thanks in advance!No, the disks are internal as is the raid controller. And strangely enough, not writing causes a high data rate, but reading! I assume that if the caches are too small the DB starts reading the indexes time and again, but 2 GB of index reading per minute??? No way, I say. Few hundred kilobytes or even a few megabytes makes sense in my opinion, but not the amount mentioned...
Truncating the tables would be a solution, but have you already tried to empty a 750 table schema with constraints and triggers implementing data inheritance? I have, and it didn't work, afterwards data consistency was not given any more...
I have already tried to delete the data in batches, each followed by a commit operation. But this brought the same result after a while, which was reading GBs of data per minute... -
903/902/BC4J can't get data-sources.xml conn pooling to work in production; help
I have several BC4J ears deployed to a 903 instance of OC4J being configured as a standalone
instance. I've had this problem since I started deploying in development on 902. So it's
some basic problem that I've not mastered.
I can't get data-sources.xml managed connection pooling to actually pool conn's. I'm wanting
to declare my jndi jdbc source connection pool in j2ee/home/config/data-sources.xml.
Have all BC4J apps get conns from this JNDI JDBC pool. I've removed all data-sources.xml from my BC4J ears,
and published the jndi jdbc source in my oc4j common data-sources.xml. I've tested that this is
the place controlling the conn URL/login passwd by commenting it out of config/data-sources.xml
and my BC4J apps then throw exceptions, can't get conn.
I've set the oc4j startup cmd line with the BC4J property to enabled connection pooling:
-Djbo.doconnectionpooling=true
symptom
Connections are created and closed. Instead of being put back into the pool managed by oc4j,
what ever BC4J is doing or my data-sources.xml is doing, the connections are just being created and
closed.
I can verify this via (solaris) lsof and netstat, where I see my oc4j instance under test load
with only 1 or 2 conns to the db box, and the ephemeral port is tumbling, meaning a new socket is
being opened for each conn. ;( grrrrrrr
Does anyone have a clue as to why this is happening?
Thanks, curt
my data-sources.xml
<data-sources>
<data-source
class="com.evermind.sql.DriverManagerDataSource"
connection-driver="oracle.jdbc.driver.OracleDriver"
ejb-location="jdbc/DEVDS"
location="jdbc/DEVCoreDS"
name="DEVDS"
password="j2train"
pooled-location="jdbc/DEVPooledDS"
url="jdbc:oracle:thin:@10.2.1.30:1521:GDOC"
username="jscribe"
xa-location="jdbc/xa/DEVXADS"
inactivity-timeout="300"
max-connections="50"
min-connections="40"
/>
</data-sources>I've run another test using local data-source.xml, that's packaged in the .ear. Still
pooling under BC4J doesn't work??
A piece of info is that the 903 oc4j release notes states that global conn pooling doesn't
work. Infering that the j2ee/home/config/data-sources.xml data sources aren't pooled or ??
I just tested so called local connection pooling, where I edited the data-sources.xml that
gets packaged in the ear, to include the min/max params and re-ran my test.
Still, the AM creates a new conn, it's to a new socket, and closes the conn when done. Causing
each conn to not be pooled, rather opened then closed to the DB box. As verified with lsof and
netstat, checking the ephemeral port # on the DB box side, always changes, meaning it's a
new socket and not an old pooled conn socket.
???? What the heck??
Surely if the AM conn check out / return code works properly, OC4J's pooling JDBC driver would
pool and not close the socket??
Has anywone gotten JDBC Datasource connections in BC4J to actually be pooled under OC4J??
Since I couldn't get this to work in my early 902 oc4j testing, and now can't get it to work
still under 903 OC4J, either it's my config or BC4J AM's code or OC4J?
Any thoughts on how to figure out what's not configed correctly or has a bug?
Thanks, curt -
Transactional Behaviour of Oracle B2B 11g
Hi Gurus/Anuj,
Can you please explain Transactional Behaviour in Oracle B2B 11g?
For a Inbound Interface I have three Mediators(Mediator M1,M2 and M3)
Partner push a file at file location --> B2B Interface used in M1 ,through B2B Binding,picks the FIle and brings to SOA and--> Give it to M2 and M3.
I need to perform Error Handling in this case..
M1 M2 and M3 are Asynchronous,Synch and Synch in nature and I guess M1 will propogate it's transaction to M2 and M2 will propogate it's transaction to M3.
Routing rules are Sequential..
Note : Fault policies are applicable to parallel routing rules only. For sequential routing rules, the fault goes back to the caller and it is the responsibility of the caller to handle the fault.
Am I correct in understanding that :
B2B Adapter in M1 is the caller and M2 and M3 ,as being Synchronous,will follow M1'a transaction.
And if a Fault goes into M2 and M3,it will go back to the caller,means M1.
And in M1 we can have Fault-Handling.
Also please explain Transactional Behaviour in Oracle B2B 11g?
Is B2B is Asynchronous in nature?
Is B2B Adapter a Transactional Adapter?
What category of JCA adapter is Oracle B2B adapter?
Thanks
Vivek
Edited by: Vivek on May 19, 2011 11:41 PM
Edited by: Vivek on May 19, 2011 11:54 PMHi Vivek,
Also please explain Transactional Behaviour in Oracle B2B 11g?Oracle B2B depends upon the underlying transport being used for transactional behavior. As far as transaction propagation is concerned, we never had any such need in B2B communication.
Am I correct in understanding that :
B2B Adapter in M1 is the caller and M2 and M3 ,as being Synchronous,will follow M1'a transaction.
And if a Fault goes into M2 and M3,it will go back to the caller,means M1.
And in M1 we can have Fault-Handling.If you are using AQ interface of B2B adapter with XA Data Source then that adapter can participate in an XA global transaction that can span multiple resources. In this transaction, the application server acts as the coordinating transaction manager with multiple databases (or other resources such as JMS), each of which is involved in a single transaction.
If you are using JMS interface of B2B adapter with XA Connection factor then that adapter can also participate in an XA global transaction that can span multiple resources.
If you are using Default (Fabric) interface of B2B adapter then it does not participate in global transaction, rather it starts it's own local transaction and executes in that. So it will totally depend upon the interface you are using with B2B adapter that it will start and propagate a global transaction or will not participate in a global transaction. Moreover, if B2B adapter is starting a transaction and propagating it to a async service then that sync service will start a new local transaction and further sync services may execute in that transaction. As soon as the control comes back to B2B adapter, it will commit the transaction.
Is B2B is Asynchronous in nature?B2B can be used for both sync and async calls (between partners). B2B is async when communicating with middleware.
Is B2B Adapter a Transactional Adapter?Explained above
What category of JCA adapter is Oracle B2B adapter?No special category. It is a specific adapter for Oracle SOA SCA composites to facilitate them in communication with Oracle B2B. You may or may not use this adapter in SOA SCA composites.
Regards,
Anuj -
Can I set the Datasource/Conn-pool credential programmatically ?
Hi all,
Within our ADF BC + Faces application, we use Crystal Report for our reporting solution.
Crystal use different db connection from one used by the ADF BC. so I create a Datasource in OAS, to be used only by Crystal Report.
Here is my problem :
We also use VPD. So I have requirement to login as DifferentUser to make the VPD run correctly.
How can I programmatically set the username and password of the datasource/conn-pool based on who is logging in to the application ?
Thank you for your help,
xtantoGood question; I don't know the answer. Try a post in the Identity Management section.
Perhaps something with Enterprise Authentication may help. -
Strange memory behaviour using the System.Collections.Hashtable in object reference
Dear all,
Recently I came across a strange memory behaviour when comparing the system.collections.hashtable versus de scripting.dictionary object and thought to analyse it a bit in depth. First I thought I incorrectly destroyed references to the class and
child classes but even when properly destroying them (and even implemented a "SafeObject" with deallocate method) I kept seeing strange memory behaviour.
Hope this will help others when facing strange memory usage BUT I dont have a solution to the problem (yet) suggestions are welcome.
Setting:
I have a parent class that stores data in child classes through the use of a dictionary object. I want to store many differenct items in memory and fetching or alteging them must be as efficient as possible using the dictionary ability of retrieving key
/ value pairs. When the child class (which I store in the dictionary as value) contains another dictionary object memory handeling is as expected where all used memory is release upon the objects leaving scope (or destroyed via code). When I use a system.collection.hashtable
no memory is released at all though apears to have some internal flag that marks it as useable for another system.collection.hashtable object.
I created a small test snippet of code to test this behaviour with (running excel from the Office Plus 2010 version) The snippet contains a module to instantiate the parent class and child classes that will contain the data. One sub will test the Hash functionality
and the other sub will test the dictionary functionality.
Module1
Option Explicit
Sub testHash()
Dim Parent As parent_class
Dim d_Count As Double
'Instantiate parent class
Set Parent = New parent_class
'Create a child using the hash collection object
Parent.AddChildHash "TEST_hash"
Dim d_CycleCount As Double
d_CycleCount = 50000
'Add dummy data records to the child container with x amount of data For d_Count = 0 To d_CycleCount
Parent.ChildContainer("TEST_hash").InsertDataToHash CStr(d_Count), "dummy data"
Next
'Killing the parent when it goes out of scope should kill the childs. (Try it out and watch for the termination debug messages)
'According to documentation and debug messages not really required!
Set Parent.ChildContainer("TEST_hash") = Nothing
'According to documentation not really as we are leaving scope but just to be consistent.. kill the parent!
Set Parent = Nothing
End Sub
Sub testDict()
Dim Parent As parent_class
Dim d_Count As Double
'Instantiate parent class
Set Parent = New parent_class
'Create a child using the dictionary object
Parent.AddChildDict "TEST_dict"
Dim d_CycleCount As Double
d_CycleCount = 50000
'Blow up the memory with x amount of records
Dim s_SheetCycleCount As String
s_SheetCycleCount = ThisWorkbook.Worksheets("ButtonSheet").Range("K2").Value
If IsNumeric(s_SheetCycleCount) Then d_CycleCount = CDbl(s_SheetCycleCount)
'Add dummy data records to the child container
For d_Count = 0 To d_CycleCount
Parent.ChildContainer("TEST_dict").InsertDataToDict CStr(d_Count), "dummy data"
Next
'Killing the parent when it goes out of scope should kill the childs. (Try it out and watch for the termination debug messages)
'According to documentation and debug messages not really required!
Set Parent.ChildContainer("TEST_dict") = Nothing
'According to documentation not really as we are leaving scope but just to be consistent.. kill the parent!
Set Parent = Nothing
End Sub
parent_class:
Option Explicit
Public ChildContainer As Object
Private Counter As Double
Private Sub Class_Initialize()
Debug.Print "Parent initialized"
Set ChildContainer = CreateObject("Scripting.dictionary")
End Sub
Public Sub AddChildHash(ByRef ChildKey As String)
If Not ChildContainer.Exists(ChildKey) Then
Dim TmpChild As child_class_hashtable
Set TmpChild = New child_class_hashtable
ChildContainer.Add ChildKey, TmpChild
Counter = Counter + 1
Set TmpChild = Nothing
End If
End Sub
Public Sub AddChildDict(ByRef ChildKey As String)
If Not ChildContainer.Exists(ChildKey) Then
Dim TmpChild As child_class_dict
Set TmpChild = New child_class_dict
ChildContainer.Add ChildKey, TmpChild
Counter = Counter + 1
Set TmpChild = Nothing
End If
End Sub
Private Sub Class_Terminate()
Debug.Print "Parent being killed, first kill all childs (if there are any left!) - muahaha"
Set ChildContainer = Nothing
Debug.Print "Parent killed"
End Sub
child_class_dict
Option Explicit
Public MemmoryLeakObject As Object
Private Sub Class_Initialize()
Debug.Print "Child using Scripting.Dictionary initialized"
Set MemmoryLeakObject = CreateObject("Scripting.Dictionary")
End Sub
Public Sub InsertDataToDict(ByRef KeyValue As String, ByRef DataValue As String)
If Not MemmoryLeakObject.Exists(KeyValue) Then MemmoryLeakObject.Add KeyValue, DataValue
End Sub
Private Sub Class_Terminate()
Debug.Print "Child using Scripting.Dictionary terminated"
Set MemmoryLeakObject = Nothing
End Sub
child_class_hash:
Option Explicit
Public MemmoryLeakObject As Object
Private Sub Class_Initialize()
Debug.Print "Child using System.Collections.Hashtable initialized"
Set MemmoryLeakObject = CreateObject("System.Collections.Hashtable")
End Sub
Public Sub InsertDataToHash(ByRef KeyValue As String, ByRef DataValue As String)
If Not MemmoryLeakObject.ContainsKey(KeyValue) Then MemmoryLeakObject.Add KeyValue, DataValue
End Sub
Private Sub Class_Terminate()
Debug.Print "Child using System.Collections.Hashtable terminated"
Set MemmoryLeakObject = Nothing
End Sub
Statistics:
TEST: (Chronologically ordered)
1.1 Excel starting memory: 25.324 kb approximately
Max memory usage after hash (500.000 records) 84.352 kb approximately
Memory released: 0 %
1.2 max memory usages after 2nd consequtive hash usage 81.616 kb approximately
"observation:
- memory is released then reused
- less max memory consumed"
1.3 max memory usages after 3rd consequtive hash usage 80.000 kb approximately
"observation:
- memory is released then reused
- less max memory consumed"
1.4 Running the dictionary procedure after any of the hash runs will start from the already allocated memory
In this case from 80000 kb to 147000 kb
Close excel, free up memory and restart excel
2.1 Excel starting memory: 25.324 kb approximately
Max memory usage after dict (500.000 records) 90.000 kb approximately
Memory released: 91,9%
2.2 Excel starting memory 2nd consequtive dict run: 27.552 kb approximately
Max memory usage after dict (500.000 records) 90.000 kb approximately
Memory released: 99,4%
2.3 Excel starting memory 3rd consequtive dict run: 27.712 kb approximately
Max memory usage after dict (500.000 records) 90.000 kb approximately
Memory released:Hi Cor,
Thank you for going through my post and took the time to reply :) Most apreciated. The issue I am facing is that the memory is not reallocated when using mixed object types and is not behaving the same. I not understand that .net versus the older methods
use memory allocation differently and perhaps using the .net dictionary object (in stead of the scripting.dictionary) may lead to similar behaviour. {Curious to find that out -> put to the to do list of interesting thingies to explore}
I agree that allocated memory is not a bad thing as the blocks are already assigned to the program and therefore should be reallocated with more performance. However the dictionary object versus hashtable perform almost identical (and sometimes even favor
the dictionary object)
The hashtable is clearly the winner when dealing with small sets of data.
The issue arises when I am using the hash table in conjunction with another type, for example a dictionary, I see that the dictionary object's memory is stacked on top of the claimed memory space of the hashtable. It appears that .net memory allocation and
reuse is for .net references only. :) (Or so it seems)
In another example I got with the similar setup, I see that the total used memory is never released or reclaimed and leakage of around 20% allocated memory remains to eventually crash the system with the out of memory message. (This is when another class
calls the parent class that instantiates the child class but thats not the point of the question at hand)
This leakage drove me to investigate and create the example of this post in the first place. For the solution with the class -> parent class -> child class memory leak I switched all to dictionaries and no leakage occurs anymore but nevertheless thought
it may be good to share / ask if anyone else knows more :D (Never to old to learn something new) -
Strange Finder behaviour since installing Mountain Lion
I've been experiencing some strange finder behaviour since updating to Mountain Lion. Folders take several seconds to open after clicking on them (and sometimes won't open at all) and files cannot be moved around the desktop or dragged on to an app. However, it is possible to open a file by clicking on it. I've tried re-booting with Snow Leopard and everything seems OK, but as soon as I go back to ML, the problem starts again.
Library is a folder, not a file. There're more than one Library folders, one at the root and one for each user in your Mac. All of them are hidden, this is why you can't find them. But you can see their contents using
Finder Menu > Go > Go to Folder
And then type:
~/Library
for your Library Folder
-or-
/Library
for the root Library folder. -
[cross posted to the j2ee forum]
I have several BC4J ears deployed to a 903 instance of OC4J being configured as a standalone
instance. I've had this problem since I started deploying in development on 902. So it's
some basic problem that I've not mastered.
I can't get data-sources.xml managed connection pooling to actually pool conn's. I'm wanting
to declare my jndi jdbc source connection pool in j2ee/home/config/data-sources.xml and
have all BC4J apps get conns from this JNDI JDBC pool. I've removed all data-sources.xml from
my BC4J ears, and published the jndi jdbc source in my oc4j common data-sources.xml.
I've tested that this is the place controlling the conn URL/login passwd by commenting it
out of config/data-sources.xml and my BC4J apps then throw exceptions, can't get conn.
I've set the oc4j startup cmd line with the BC4J property to enabled connection pooling:
-Djbo.doconnectionpooling=true
symptom
Connections are created and closed. Instead of being put back into the pool managed by oc4j,
what ever BC4J is doing or my data-sources.xml is doing, the connections are just being created and
closed.
I can verify this via (solaris) lsof and netstat, where I see my oc4j instance under test load
with only 1 or 2 conns to the db box, and the ephemeral port is tumbling, meaning a new socket is
being opened for each conn. ;( grrrrrrr
Does anyone have a clue as to why this is happening?
Thanks, curt
my data-sources.xml
<data-sources>
<data-source
class="com.evermind.sql.DriverManagerDataSource"
connection-driver="oracle.jdbc.driver.OracleDriver"
ejb-location="jdbc/DEVDS"
location="jdbc/DEVCoreDS"
name="DEVDS"
password="j2train"
pooled-location="jdbc/DEVPooledDS"
url="jdbc:oracle:thin:@10.2.1.30:1521:GDOC"
username="jscribe"
xa-location="jdbc/xa/DEVXADS"
inactivity-timeout="300"
max-connections="50"
min-connections="40"
/>
</data-sources>Thanks Leif,
Yes, set it to the location jndi path.
A piece of info is that the 903 oc4j release notes states that global conn pooling doesn't
work. Infering that the j2ee/home/config/data-sources.xml data sources aren't pooled or ??
I just tested so called local connection pooling, where I edited the data-sources.xml that
gets packaged in the ear, to include the min/max params and re-ran my test.
Still, the AM creates a new conn, it's to a new socket, and closes the conn when done. Causing
each conn to not be pooled, rather opened then closed to the DB box. As verified with lsof and
netstat, checking the ephemeral port # on the DB box side, always changes, meaning it's a
new socket and not an old pooled conn socket.
???? What the heck??
Surely if the AM conn check out / return code works properly, OC4J's pooling JDBC driver would
pool and not close the socket??
Has anywone gotten JDBC Datasource connections in BC4J to actually be pooled under OC4J??
Since I couldn't get this to work in my early 902 oc4j testing, and now can't get it to work
still under 903 OC4J, either it's my config or BC4J AM's code or OC4J?
Any thoughts on how to figure out what's not configed correctly or has a bug?
Thanks, curt -
Strange repaint behaviour with JList & Keyboard actions
Hi everyone,
This is my first post to the forum. You guys have been a great help in the past and I hope to contribute more in the future.
Anyways, I've encountered some strange repainting behaviour with a JDialog that uses a JList and a JButton. The dialog is fairly straight-forward and basically this is how it works (like an open file dialog - yes I'm implementing my own filechooser of sorts):
* JList lists a number of simple items that the user can select from.
* Once a selection is made, an Open button (JButton) is enabled.
* <ENTER> key is registered (using registerKeyboardAction()) with a JPanel which is used as the main content pane in the dialog.
* The user can either click on the Open Button or hit the <ENTER> key which then closes the dialog and runs whatever logic that needs to.
Now, the repaint problem comes in when:
1. User selects an item.
2. User hits the <ENTER> button
3. Dialog closes
4. User brings the dialog back up. This entails reloading the list by removing all elements from the list and adding new ones back in.
5. Now... if the user uses the mouse to select an item lower in the list than what was done in step #1, the selection is made, but the JList doesn't repaint to show that the new selection was made.
I didn't include a code sample because the dialog setup is totally straight-forward and I'm not doing anything trick (I've been doing this kind of thing for years now).
If I remove the key registration for the <ENTER> key from the dialog, this problem NEVER happens. Has anyone seen anything like this? It's a minor problem since my workaround is to use a ListSelectionListener which manually calls repaint() on the JList inside the valueChanged() method.
Just curious,
HuyOh, my bad. I'm actually using a JToggleButton and not a JButton, so the getRootPane().setDefaultButton() doesn't apply because it only takes JButton as an input param. I wonder why it wasn't implemented to take AbstractButton. hmmm.
-
Strange layout behaviour with TilePane
here is the demo
1.rootLayout have 2 child,controlbox and contentLayout
2.3 button on controlbox
3.contentLayout will add content,when press deffrent button on controlbox
4.watch button "Add TilePane" , strange layout behaviour , what is the matter?
layout picture
|--------------------------------|
| | |
| | |
| | |
| | |
|controlbox | contentLayout |
| (VBox) | (StackPane) |
| | |
| | |
| | |
| | |
|--------------------------------|
the code
import javafx.application.Application;
import javafx.event.EventHandler;
import javafx.geometry.Pos;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.control.ListView;
import javafx.scene.input.MouseEvent;
import javafx.scene.layout.StackPane;
import javafx.scene.layout.TilePane;
import javafx.scene.layout.VBox;
import javafx.stage.Stage;
public class testTilePaneLayout extends Application {
StackPane contentLayout = new StackPane();
//add content with 2 Button
public void addContent(){
VBox vbox = new VBox();
contentLayout.getChildren().clear();
contentLayout.getChildren().add(vbox);
StackPane.setAlignment(vbox,Pos.CENTER);
Button btn = new Button("Button1");
Button btn2= new Button("Button2");
vbox.getChildren().add(btn);
vbox.getChildren().add(btn2);
//add content with 2 Button & 1 ListView
public void addListViewContent(){
VBox vbox = new VBox();
contentLayout.getChildren().clear();
contentLayout.getChildren().add(vbox);
StackPane.setAlignment(vbox,Pos.CENTER);
Button btn = new Button("Button1");
Button btn2= new Button("Button2");
vbox.getChildren().add(btn);
vbox.getChildren().add(btn2);
@SuppressWarnings("rawtypes")
ListView listView = new ListView();
vbox.getChildren().add(listView);
//add content with 2 Button & 1 TilePane
public void addTilePaneContent(){
VBox vbox = new VBox();
contentLayout.getChildren().clear();
contentLayout.getChildren().add(vbox);
StackPane.setAlignment(vbox,Pos.CENTER);
Button btn = new Button("Button1");
Button btn2= new Button("Button2");
vbox.getChildren().add(btn);
vbox.getChildren().add(btn2);
TilePane tilePane = new TilePane();
tilePane.setMaxSize(100,100);
Label lbl = new Label("Label on TilePane");
tilePane.getChildren().add(lbl);
vbox.getChildren().add(tilePane);
public void start(Stage stage) {
stage.setResizable(false);
stage.centerOnScreen();
Group root = new Group();
Scene scene = new Scene(root,800,600);
stage.setScene(scene);
//root Layout = StackPane
StackPane rootLayout = new StackPane();
root.getChildren().add(rootLayout);
rootLayout.setMinSize(800,600);
rootLayout.setMaxSize(800,600);
//content StackPane
rootLayout.getChildren().add(contentLayout);
contentLayout.setMinSize(100, 100);
contentLayout.setMaxSize(200, 200);
StackPane.setAlignment(contentLayout,Pos.CENTER);
//control VBox
VBox controlBox = new VBox();
rootLayout.getChildren().add(controlBox);
controlBox.setMaxSize(100, 200);
StackPane.setAlignment(controlBox,Pos.CENTER_LEFT);
//3 control button
Button btn1 = new Button("Add button");
Button btn2= new Button("Add Listview");
Button btn3= new Button("Add TilePane");
controlBox.getChildren().add(btn1);
controlBox.getChildren().add(btn2);
controlBox.getChildren().add(btn3);
btn1.setOnMousePressed(new EventHandler<MouseEvent>() {
@Override
public void handle(MouseEvent arg0) {
addContent();
btn2.setOnMousePressed(new EventHandler<MouseEvent>() {
@Override
public void handle(MouseEvent arg0) {
addListViewContent();
btn3.setOnMousePressed(new EventHandler<MouseEvent>() {
@Override
public void handle(MouseEvent arg0) {
addTilePaneContent();
stage.show();
public static void main(String[] args) {
Application.launch(args);
}Edited by: noregister on Oct 4, 2011 11:30 AM
Edited by: noregister on Oct 4, 2011 11:31 AMOh, my bad. I'm actually using a JToggleButton and not a JButton, so the getRootPane().setDefaultButton() doesn't apply because it only takes JButton as an input param. I wonder why it wasn't implemented to take AbstractButton. hmmm.
-
Strange JTable behaviour - everything is highlighted
Hello all,
im experiencing some strange JTable behaviour, and im not so sure why. When i run my program, the JTable appears, but all the cells are highlighted in advance. Also, i can now only select one cell at a time. I have set myTable.setSelectionModeListSelectionModel.SINGLE_INTERVAL_SELECTION); myTable.setCellSelectionEnabled(true);and my renderer code is below. I call the renderer by using the setDefaultRenderer method with(Object.class,myRenderer).
I have also changed isCellEditable to return true. If i dont use Object.class, and try to use my own custom class, the JTable is not all highlighted, but it doesnt seem to use myRenderer, and when i click on the header of Column A, all cells from column B and beyond become highlight, which is not normal behaviour. I thought the colum you selected should be highlighted.
Sorry for the long post, i hope the above makes sense...this is really quite bizzare, and im not so sure why this is happening. Thanks for any advice you can give, regards, Rupz
import javax.swing.*;
import javax.swing.table.DefaultTableCellRenderer;
import javax.swing.border.*;
import java.awt.Component;
import java.awt.Color;
import java.awt.Rectangle;
import java.util.*;
import java.awt.*;
public class MyTableCellRenderer extends DefaultTableCellRenderer{
private Font cellFont;
private LineBorder selectBorder;
private EmptyBorder emptyBorder;
public MyTableCellRenderer() {
super();
setOpaque(true);
emptyBorder = new EmptyBorder(1, 2, 1, 2);
cellFont = new Font("Times", Font.PLAIN, 10);
setFont(cellFont);
selectBorder = new LineBorder(Color.red);
private boolean isHeaderCell(int row, int column){return column == 0;}
public Component getTableCellRendererComponent (JTable myTable, Object value, boolean isSelected, boolean hasFocus, int row, int column){
//super.getTableCellRendererComponent(myTable, value, isSelected, hasFocus,row, column);
if (isSelected){
super.setForeground(myTable.getSelectionForeground());
super.setBackground(myTable.getSelectionBackground());
setBorder(selectBorder);
else{
super.setForeground(myTable.getSelectionForeground());
super.setBackground(myTable.getSelectionBackground());
setBorder(emptyBorder);
if (hasFocus) {
setBorder(selectBorder);
if (myTable.isCellEditable(row,column)) {
super.setForeground(UIManager.getColor("Table.focusCellForeground"));
super.setBackground(UIManager.getColor("Table.focusCellBackground"));
else {setBorder(noFocusBorder);}
setValue(value, isSelected, hasFocus, row, column);
// Color bDis = getBackground();
// boolean colourEquals = (bDis != null) && (bDis.equals(myTable.getBackground()) ) & myTable.isOpaque();
// setOpaque (!colourEquals);
return this;
public void setValue (Object value, boolean hasFocus, boolean isSelected, int row, int column){
if (value instanceof myCell){
myCell foo = (myCell)value;
Object data = foo.getValue(row,column);
if (isHeaderCell(row, column)) {
//label cells are center aligned
setHorizontalAlignment(JTextField.CENTER);
}else {
if (data instanceof Number) {
//numbers are right justified
setHorizontalAlignment(JTextField.RIGHT);
}else {
//everything else is left justified
setHorizontalAlignment(JTextField.LEFT);
//value to display in table
setText((data == null) ? "" : data.toString());
else {
//not cell object so render with toString of that object
setText((value == null) ? "" : value.toString());Hi VV!
thanks for the reply - now the table isnt all highlight when loaded, but as for cell celection..thats a different matter. I did have myTable.setCellSelectionEnabled(true); but no, the cell behaviour is really, eally weird, quite hard to explain, but here goes.
If i try to select cell D1 and D2 - D1 is selected, D2, E2,F2 and so on become selected. If i try to add D3 to the mix, the entire row 3 is selected, and as soon as i let go of the mouse button, the entire table except row 1 gets selected. really really weird. Below is my tableModel and what i do to the table. Thanks for your help,
regards
Rupz
myTable.setModel(new myTableModel(this,40,40));
// Create a row-header to display row numbers.
// This row-header is made of labels whose Borders,
// Foregrounds, Backgrounds, and Fonts must be
// the one used for the table column headers.
// Also ensure that the row-header labels and the table
// rows have the same height.
numRows = myTable.getColumnCount();
numCols = myTable.getRowCount();
TableColumn aColumn = myTable.getColumnModel().getColumn(0);
TableCellRenderer aRenderer = myTable.getTableHeader().getDefaultRenderer();
Component aComponent = aRenderer.getTableCellRendererComponent(myTable, aColumn.getHeaderValue(), false, false, -1, 0);
Font aFont = aComponent.getFont();
Color aBackground = aComponent.getBackground();
Color aForeground = aComponent.getForeground();
Border border = (Border)UIManager.getDefaults().get("TableHeader.cellBorder");
FontMetrics metrics = getFontMetrics(cellFont);
* Creating a panel to be used as the row header.
* Since I'm not using any LayoutManager,
* a call to setPreferredSize().
JPanel pnl = new JPanel((LayoutManager)null);
Dimension dim = new Dimension( 40, rowHeight*numRows);
pnl.setPreferredSize(dim);
// Adding the row header labels
dim.height = rowHeight;
for (int ii=0; ii<numRows; ii++) {
JLabel lbl = new JLabel(Integer.toString(ii+1), SwingConstants.CENTER);
lbl.setFont(aFont);
lbl.setBackground(aBackground);
lbl.setForeground(aForeground);
lbl.setBorder(border);
lbl.setBounds(0, ii*dim.height, dim.width, dim.height);
pnl.add(lbl);
JViewport vp = new JViewport();
dim.height = rowHeight*numRows;
vp.setViewSize(dim);
vp.setView(pnl);
// Set resize policy and make sure
// the table's size is tailored
// as soon as it gets drawn.
myTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
Dimension dimScpViewport = myTable.getPreferredScrollableViewportSize();
if (numRows>30) dimScpViewport.height = 30*rowHeight;
else dimScpViewport.height = numRows*rowHeight;
if (numCols>15)
dimScpViewport.width = 15*myTable.getColumnModel().getTotalColumnWidth()/numCols;
else
dimScpViewport.width = myTable.getColumnModel().getTotalColumnWidth();
myTable.setPreferredScrollableViewportSize(dimScpViewport);
myTable.repaint();
And the table model
public class myTableModel extends DefaultTableModel {
private MySpread mySpreadsheet;
public myTableModel (MySpread aSpreadsheet){
super();
mySpreadsheet = aSpreadsheet;
public myTableModel (MySpread aSpreadsheet, int rows,int cols){
super(rows,cols);
// for(int x = 0; x < rows; x++) {
// myCell temp = new myCell(new Integer(x+1));
// super.setValueAt(temp, x, 0);
for(int x =0 ; x < rows; x++)
for (int y = 0; y < cols; y++)
// we initialize it here
super.setValueAt(new myCell(rows,cols,("")),x,y);
mySpreadsheet = aSpreadsheet;
public boolean isCellEditable(int row, int column) {return true;}
-
Strange POF behaviour in 3.6.1.3
Hi All,
We have been seeing some strange POF behaviour in 3.6.1.3 paricularly around classes with boolean fields.
Here is my test case:
package org.gridman.pof;
import com.rbs.odc.dashboard.server.cluster.model.Case;
import com.tangosol.io.pof.ConfigurablePofContext;
import com.tangosol.io.pof.PofReader;
import com.tangosol.io.pof.PofWriter;
import com.tangosol.io.pof.PortableObject;
import com.tangosol.io.pof.reflect.PofValue;
import com.tangosol.io.pof.reflect.PofValueParser;
import com.tangosol.io.pof.reflect.SimplePofPath;
import com.tangosol.util.Binary;
import com.tangosol.util.ExternalizableHelper;
import java.io.IOException;
public class JK implements PortableObject {
private String stringField;
private boolean booleanFieldOne;
private boolean booleanFieldTwo;
public JK() {
public JK(boolean booleanFieldOne, boolean booleanFieldTwo, String stringField) {
this.booleanFieldOne = booleanFieldOne;
this.booleanFieldTwo = booleanFieldTwo;
this.stringField = stringField;
@Override
public void readExternal(PofReader pofReader) throws IOException {
stringField = pofReader.readString(0);
booleanFieldOne = pofReader.readBoolean(1);
booleanFieldTwo = pofReader.readBoolean(2);
@Override
public void writeExternal(PofWriter pofWriter) throws IOException {
pofWriter.writeString(0, stringField);
pofWriter.writeBoolean(1, booleanFieldOne);
pofWriter.writeBoolean(2, booleanFieldTwo);
public static void main(String[] args) {
ConfigurablePofContext pofContext = new ConfigurablePofContext("jk-pof-config.xml");
JK value = new JK(false, true, "JK");
Binary binary = ExternalizableHelper.toBinary(value, pofContext);
PofValue pofValue = PofValueParser.parse(binary, pofContext);
PofValue childOne = new SimplePofPath(0).navigate(pofValue);
PofValue childTwo = new SimplePofPath(1).navigate(pofValue);
PofValue childThree = new SimplePofPath(2).navigate(pofValue);
System.out.println(childOne.getValue());
try {
System.out.println(childTwo.getValue());
} catch (Exception e) {
System.out.println("Exception: " + e.getMessage());
try {
System.out.println(childThree.getValue());
} catch (Exception e) {
System.out.println("Exception: " + e.getMessage());
}and the jk-pof-config.xml file used above...
<pof-config>
<user-type-list>
<include>coherence-pof-config.xml</include>
<user-type>
<type-id>3001</type-id>
<class-name>org.gridman.pof.JK</class-name>
</user-type>
</user-type-list>
</pof-config>When you run the main method of the class above you would expect to get
JK
false
true... but what you get is...
JK
null
Exception: -34 is an invalid typeWhat is going on? The booleanFieldOne seems to have been serialized as type -34 which is PofConstants.V_BOOLEAN_TRUE which makes sense but the code to deserialize the field cannot handle type -34. The booleanFieldTwo comes back as null and is serialized as type -65 which is PofConstants.T_UNKNOWN
Where this causes us a problem is if we do a query with a filter like this...
new EqualsFilter(new PofExtractor(null, 1), true);...it will break whenever it tries to extract the POF value where booleanFieldOne is true.
I know we can fix this by always specifying the type, so this will work
new EqualsFilter(new PofExtractor(Boolean.class, 1), true);and this will work too wheras it fails without specifying the type...
childTwo.getValue(Boolean.class);So although there are work-arounds it seems very strange.
What is even stranger is that if you do not serialize the stringField so the readExternal and writeExtrnal methods look like this
@Override
public void readExternal(PofReader pofReader) throws IOException {
//stringField = pofReader.readString(0);
booleanFieldOne = pofReader.readBoolean(1);
booleanFieldTwo = pofReader.readBoolean(2);
@Override
public void writeExternal(PofWriter pofWriter) throws IOException {
//pofWriter.writeString(0, stringField);
pofWriter.writeBoolean(1, booleanFieldOne);
pofWriter.writeBoolean(2, booleanFieldTwo);
}The you get this output...
null
false
Exception: -34 is an invalid typeiNow the stringField is null (as we have not serialized it) but the booleanFieldOne is now being desrialized correctly as a boolean false. We have noticed that if you have a boolean as the first field you serialize in the writeExternal method then it is serialized as POF type -11 which is PofConstants.T_BOOLEAN and will be deserialized as the correct true or false value.
Cheers,
JKHi René,
Just changing the field types to Boolean like this...
private Boolean booleanFieldOne;
private Boolean booleanFieldTwo;made no difference. But then changing the writeExternal method to use writeObject instead of writeBoolean did fix it and the types of both fields are -11 or PofConstants.T_BOOLEAN
@Override
public void writeExternal(PofWriter pofWriter) throws IOException {
pofWriter.writeString(0, stringField);
pofWriter.writeObject(1, booleanFieldOne);
pofWriter.writeObject(2, booleanFieldTwo);
}So using writeObject instead of writeBoolean would be another fix, but obviously most people would pick writeBoolean to store a boolean value.
JK -
Strange JFRAME behaviour under Jdk 1.5
I have the following extracted code :
import java.util.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.border.*;
import java.awt.geom.*;
public class DrawPie extends JFrame{
private HashMap ColourMap=new HashMap();;
private HashMap DataMap=new HashMap();
private double Total_Val=0;
private int startAngle=0;
private int arcAngle=0;
public DrawPie(HashMap DataMap){
super ("Pie Chart Analysis");
this.DataMap=DataMap;
// System.out.println("DATAMap-->"+DataMap);
// getContentPane().setBackground(Color.white);
setSize(500,500);
setVisible(true);
public void paint(Graphics g){
super.paint (g);
Graphics2D g2 = (Graphics2D) g;
DrawPieChart(g);
This programme work fine under jdk1.4.2 or below at the time when the Jframe or windows is resized or icon minimised or maximised.
But when it was compiled using latest jdk1.5 , unexpected strange result happen , the pie chart draw using java 2d
g2.fill(new Arc2D.Double(30, 30, 200,200,startAngle,arcAngle
, Arc2D.PIE));
wil behaved strangely, the moment the JFrame or windows is resize or dragged.
The pie chart will disappear if the windows is resized , However if the window is minimised and restore back to normal size , pie chart will reappear and subsequently lost completely if the windows is dragged resulted in the size changes.
I was puzzled by this strange swing behaviour , any resized or windows minimise or maximise would not result in the lost of pie chart as long as the jdk is not 1.5 ! Was it due to swing fundamental changes incorporated in the latest release?
Any suggestion?
Thankok I see what you have done,
now a few tips in drawing something on your frame:
never override the paint method of your main Frame (like you did)
to draw something on it you simply override the contentPane's paint method
and to make your own contentPane you simply make one by making a new Class
that extends say JPanel and assign it as a contentPane of your Frame(like I did)
And in this Paint method you can draw whatever you like it will be properly uptated!!!
All the best keep up the good work!
ps. try the code bellow.
import javax.swing.*;
public class DrawPie1 extends JFrame {
private double Total_Val=0;
private int startAngle=0;
private int arcAngle=0;
private MyMainPanel mainPan;
public DrawPie1()
super ("Pie Chart Analysis");
mainPan = new MyMainPanel();
setContentPane(mainPan);
//public void paint(Graphics g) //Do not override the paint method of your main frame!!
// super.paint (g);
// Graphics2D g2 = (Graphics2D) g;
// g2.setPaint(Color.red);
// g2.fill(new Arc2D.Double(30, 30, 200,200,0,78
// , Arc2D.PIE));
public static void main(String args[])
DrawPie1 pie=new DrawPie1();
pie.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
pie.setSize(400,300);
pie.setVisible(true);
//**** Second Class
import javax.swing.*;
import java.awt.*;
import java.awt.geom.Arc2D;
public class MyMainPanel extends JPanel
public MyMainPanel()
public void paint(Graphics g)
super.paint (g);
Graphics2D g2 = (Graphics2D) g;
g2.setPaint(Color.red);
g2.fill(new Arc2D.Double(30, 30, 200,200,0,78
, Arc2D.PIE));
}
Maybe you are looking for
-
Acrobat 8.0 Distiller problem - please help
I have Adobe 8.0 Profeessional installed on a vista machine. I am trying to .pdf some lotus apporach reports into the distiller. The distiller launches and acrobat launches fine. When I choose the distiller printer and am asked for a file name and lo
-
I know it defeats the purpose of the iCloud, but I would like to have some (if not all) of my iCloud music available on my iPad. I'm not always able to get a wifi signal and it would be nice to have these files actually on my iOS device. Is there a s
-
Foreign trade data is incomplete
Dear sap gurus, when i try to create a rush order, in billing when i try to save, the system throws the error foreign trade data is incomplete so it cannot pass into accounting. for cash sales and other sale order the system does not throw any error,
-
Close document without exiting program
In Dreamweaver 6, before I got a new computer, I could close a document window and the program would go back to a blank New Document screen. Now the entire program closes, and I can't find how to close a document without exiting the program. Does any
-
Handling two transactions in session method at a time
Hi frnds now im facing problem in handling two transactions in session method fs00,fspo at a time. i want some info.on how to handle two transactions at a time thanx