Al Wells

Ranch Hand
+ Follow
since Apr 18, 2005
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Al Wells

I have a TimerTask that looks for a file on a directory. Once it sees
the file, it parses it and puts it in the DB using several objects.
After all of that is done, the system is supposed to delete the file
so that it does not just sit there parsing it. But, there seems to be
a lock on the directory. I can't even delete it manually when
the timertask is polling.

How do I kill the timertask long enough to delete a file through
the software using: boolean isDeleted = file.delete();? No one
monitors these directories. I have created a system that allows files
to be uploaded to the hard drive (automatically) and then once parsed,
I need the files to be killed or my timer will just keep parsing the
files over and over again. Any thoughts? The code that is not working
is below.




In summary, Another class (not shown) invokes the TimeLapFiles class.
That class is the invoker. It polls every 10 seconds. The file
takes miliseconds to process so there should be no use of the file by
the time that the delete method is called. But the lock on the
directory won't allow any delete at all.

For those of you form the US, happy 4th!

Cheers,
Al
[ July 01, 2005: Message edited by: Al Wells ]
18 years ago
Thanks very much. I will check into using those classes and see what looks best. I don't have a web-app. There is a web app but that one is for connected users. In this case, there is not even a GUI on the server. Just the listener and a timer that polls directories for new files as well as generates files at day's end. I could build a web-app though and forgo the socket. Thanks for pointing me in a direction that might be useful.

All the best,
Al
18 years ago
I have created a Swing app that users collect remote data through (as well as other things). Once the day is done, multiple users connect to the internet and select the "Synch" button. Objects then query the local DB and generate XML files from each table in the local DB.

Now that the XML files are created, I need to upload the files to the server app where they will be parsed and loaded into the main DB. The next morning, the server app will then download all of the files to the user directory where they will be parsed and loaded into the user's local DB.

So, I have local files and remote files. I need to pass them to each respective location and have no web-app that will take care of this. I am assuming that I will use a socket connection (right?). Can anyone point me to resources that will help me to figure out how to do this uploading and downloading. BTW, there will be no browse feature in this app. The uploading and downloading must happen automatically based on logic in the app.

Thanks for your help.
18 years ago
Finally figured it out. Why does that happen after hours of thinking but
only after I post... In any event, here is what I did:



Now to test it.
18 years ago
Luckily I am married...

I pretty much copied the following from the Java tutorial. I have tried
all kinds of imports to no avail. Why will the following not compile?



The compiler gives me the following:

C:\SMLocal\SMLogic>javac DateReporter.java
DateReporter.java:7: cannot find symbol
symbol : class DateFormat
location: class DateReporter
DateFormat dateFormatter;
^
DateReporter.java:13: cannot find symbol
symbol : variable DateFormat
location: class DateReporter
dateFormatter = DateFormat.getDateInstance(DateFormat.SHORT, currentLocale);
^
DateReporter.java:13: cannot find symbol
symbol : variable currentLocale
location: class DateReporter
dateFormatter = DateFormat.getDateInstance(DateFormat.SHORT, currentLocale);
^
DateReporter.java:13: cannot find symbol
symbol : variable DateFormat
location: class DateReporter
dateFormatter = DateFormat.getDateInstance(DateFormat.SHORT, currentLocale);
^
4 errors
18 years ago
Thanks. I will review that article right away.
18 years ago
Thank you very much.

I should clarify that the XML docs that are generated are pushed to the recieving location and then handled off line. The reason that there are two synchs each day is to make sure that synchs only happen after all users have reported in (incoming can happen any time but outgoing only after all incoming has been completed). So, the local machine generates an XML doc through a synch button in the swing app. That in turn is uploaded to the enterprise server where all the XML data is then parsed and loaded into the main DB. Once all users have reported in, the enterprise system generates XML docs for each table which are in turn downloaded to the local systems and then parsed and put in the local Access DB. Some of these tables (and subsequently the XML docs generated) will be huge. Do you think that JAXB is the right approach in this configuration? I am currently reading up on JAXB and have downloaded jwsdb 1.5. It sounds pretty interesting and it looks like all I have to do to get the variables out of the doc is to say myVar = node.getVar(); (or some such thing).

Thanks for the help.
18 years ago
I am building a synchronization solution for an app that has a local Access database and is not connected to the web or enterprise app when it collects data. I need to get data from the local app to the enterpise app and from the ent app to the local app twice each day when the user connects to the internet.

I have successfully built all of the XML docs that I need to use. They will be generated twice a day as well (one for incoming and one for outgoing). Building XML with Java was so simple I could not believe it. But, I am having a challenge with using the XML docs now that they are built.

I am not sure how I go about reading these docs in the code and then inserting the multiple rows of data into the respective database. Following is an example of the local XML doc build:

<?xml version="1.0" encoding="UTF-8" ?>
- <AssetOutXML>
<AssetID>5222935</AssetID>
<CompanyID>1</CompanyID>
<AssetTypeID>4</AssetTypeID>
<Code>1</Code>
<Serial>1</Serial>
<Active>1</Active>
<addUserID>1</addUserID>
<addDate>2005-06-13 20:58:49</addDate>
<AssetID>422627</AssetID>
<CompanyID>1</CompanyID>
<AssetTypeID>422700</AssetTypeID>
<Code>111</Code>
<Serial>111</Serial>
<Active>1</Active>
<addUserID>1</addUserID>
<addDate>2005-06-14 09:27:27</addDate>
<AssetID>3439544</AssetID>
<CompanyID>1</CompanyID>
<AssetTypeID>4</AssetTypeID>
<Code>125</Code>
<Serial>125</Serial>
<Active>1</Active>
<addUserID>1</addUserID>
<addDate>2005-06-14 09:48:37</addDate>
<AssetID>50138776319978073038569312956746906</AssetID>
<CompanyID>1</CompanyID>
<AssetTypeID>3393406</AssetTypeID>
<Code>956</Code>
<Serial>956</Serial>
<Active>1</Active>
<addUserID>1</addUserID>
<addDate>2005-06-15 16:19:17</addDate>
<AssetID>1096443</AssetID>
<CompanyID>1</CompanyID>
<AssetTypeID>2121589</AssetTypeID>
<Code>155</Code>
<Serial>155</Serial>
<Active>1</Active>
<addUserID>1</addUserID>
<addDate>2005-06-14 09:53:22</addDate>
<AssetID>1982671</AssetID>
<CompanyID>1</CompanyID>
<AssetTypeID>4</AssetTypeID>
<Code>133</Code>
<Serial>133</Serial>
<Active>1</Active>
<addUserID>1</addUserID>
<addDate>2005-06-14 10:04:17</addDate>
<AssetID>6</AssetID>
<CompanyID>1</CompanyID>
<AssetTypeID>6</AssetTypeID>
<Code>122</Code>
<Serial>122</Serial>
<Active>1</Active>
<addUserID>1</addUserID>
<addDate>2005-06-14 19:28:53</addDate>
<RecordCount>7</RecordCount>
</AssetOutXML>

Now, what do I do to read this XML doc and insert all the records into their respective rows?

If reading is nearly as simple as creating was, this has to be very easy. The tutorials and samples I read all show parsing an entire XML doc and priting it to the consol. I need to read a record and then put that record in the DB and then read the next one and so on (I suppose using SAX)? Do I need to assign each item to a variable or can I just create a resultset which will just insert records as they come in? Can someone give me an example and/or point me to a resource that gives an example along these lines?

Thanks so much,
Al
18 years ago
I know that I have said this to you before but, you are the man. So, now I know. I have to re-declare the variable explicitly in the constructor if that is the only place that it occurs and I want it to be usable by an inner class and I don't have a method where it is passing. That works just like it should.
18 years ago
Ernest,

Thanks for the help. I must admit that I am still a little in the dark (no surprise there).

myVar is not static. It is passed from another class. When I tried creating classes without myVar in main, I got constructor errors in the compiler. Granted that I only have a main in order to compile and run each class on its own just so that I can make sure that I have no syntax errors. In this example, I do have a couple. I would have to have String myVar declared in main as well in order for the compiler not to throw an error when I try to javac the file. I also should have written new MyClass(String myVar) and then public MyClass(String myVar) where myVar is created and initialized in some other class which calls this constructor. That is only learned from having tried it the other way.

public SomeOtherClass {

String myVar = "The value";//here it is initialized

MyClass passMyVar = new MyClass(myVar);//here it passes fine.

}//close class

public MyClass{

String myVar;

public MyClass(String myVar) {

//myVar is intialized here but not in inner class. But, if I pass it here it is fine.
MyOtherClass passMyVarAgain = new MyOtherClass();
passMyVarAgain.getReturnValue(myVar) //passes fine with the value that I expect it to have.

}//close constructor

private ActionListener {
public method {
MyOtherClass passMyVarAgain = new MyOtherClass();
passMyVarAgain.getReturnValue(myVar); //myVar is now null. But, if not declared as an instance variable for the class, I get a compiler error.

}//close method
}//close inner class
}//close class

Does that make some sense? I know, I can see you laughing...

All of this is due to my inexperience and learning on the fly I am very sure. myVar actually gets initialized in another class where it is returned and then passed to this class. So, I thought that myVar is automatically assigned the value that is returned from the other class. Now I want to pass that value to yet another object in order for that object to do what it does. Do I need to initialize another variable in the constructor and then pass that variable? Something like String myOtherVar = myVar (I gather from your response that this is not right either)? Or is there some other way that I need to go about it?

Thanks for your help, Ernest. I am sure that I will get this with a little more help. Most of the items that you have helped me with I have learned quickly but this one is giving me a little more trouble.

All the best,
Al
18 years ago
I have a question about how to pass a variable in the outer class to an inner class for use. I have used a println function to see that my variable is null when I try it as it is shown below. However, it prints out fine in the constructor and the main class itself. The variable is comming from another object but I want to continue to use it as I instatiate even more objects. Right now I am solving this problem through a clunky work around. Hopefully this makes sense.

I created an example of what I am try to do in order to clarify.

18 years ago
Thanks Ernest. That explains a lot.

Got it working.
18 years ago
I converted a panel to a frame to make the flow of the program a little
better. But, only the first panel and the last label of this class are
now showing on the frame (the other panel is not). What am I missing?

I have some things being put in panels and some things placed directly
on screen. The last label ('thirdWarn') is displaying and the first panel
(eqTypePanel) is showing and nothing else is.

18 years ago
How do I add a vector to JTable and get it to display. What I
have tried is not working. I am also interested in other
methods I can use to accomplish the same thing but that may also be
more visually pleasing to the user.

I tried building the vector and then just adding it to the table.
That did not work. The code follows and I thank you for your assistance.


[ June 02, 2005: Message edited by: Al Wells ]
18 years ago
Wish I would have refreshed the page...

I finally figured that out and just got it all working.

The great thing about learning the hard way is that once it is learned,
it is learned. I finally got the row to insert into the DB!

I can not figure out why you have a virtual cursor in Java. It would make
sense to me that a Select with a WHERE which returns only one record
would mean that there is only one record and therefore that is the
record that is desired. But, now at least I know.

Thanks for your help.