Jeremy McNally

Ranch Hand
+ Follow
since Feb 21, 2014
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
11
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Jeremy McNally

If you listened to my post, you could (in the Application-Context.xml) use the PropertyPlaceholderConfigurer class in a bean declaration if you are using Spring and declare your properties files there as

<bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name = "locations">
<list>
<value>dfedfd.properties</value>
</list>
</property>
</bean>

Than you would create a bean that with getters and setters. Inside the app context xml file you can set those properties to the names of your properties in your properties file. Check it out. Could help. Other ways of doing this too.
8 years ago
You can put your custom properties files in a Resources folder under your project root. Dependent on how you want to use them, there are various methods of doing it that you can research. I usually just create my own folder for my properties files under the project root. Others may do it differently... You can do it right under your SRC folder if you want too...
8 years ago
Your dispatcher-servlet.xml file is to declare your dispatcher and stuff like that. In an application-context.xml file (which you would include) is meant to define your beans. Your beans are of the implementation classes generally, although there are many other uses for declaring a bean. Those implementation classes you would declare as a bean in my example, usually implement an interface in Spring. That way, if you are in your Service layer for example, you can autowire your variable of type (whatever the name is of the interface you are implementing) such as:

@Autowired
InterfaceName theIdOfYourBean;

Now you can use the implementation class you declared in your BEAN declaration in the App context. All of those methods will be available to you (ONLY IF) you wrote a signature for it in your interface and implemented it in the class you are wiring to...


I hope it helps your understanding in a general sense. It should give you a conceptual idea and something to base your research around. I'd get into further detail and explain things better if I had time.
Good luck! Spring... the hardest part is getting past 'understanding how it works' / the concept. Once you get that, you will get it all and it will easily click for you. It seems like it wasn't so long ago I was in your shoes...

8 years ago
One question I have... when I retrieve the TIMESTAMP and store it in a Timestamp variable after retrieving the date/time from the ResultSet, do you know if I'll need to do anything else with it before passing it into the script in SQL Server? If not, I'll find out anyway by trial and error...
8 years ago
In that case, I would want to change the datatype in Oracle to be TIMESTAMP and then use the getTimeStamp() method of the ResultSet class to get the date/time while storing it in a variable of type Timestamp. If I'm off on anything I just said, please let me know.
I'll be working on the solution today based off the feedback I received on this post and I'll keep this thread updated with the results and or questions pertaining to it.

Thank you for your response.
8 years ago
Also, thank you for your response.
8 years ago
If I store it in Oracle as a date, I'm not able to get the time back. I am only able to get the date out of it. If I store it in Oracle as a String and convert it to a date at that point I can then pass it to the SQL Server script to do my comparisons I need. Initially, I tried to pass it into the script as a String since all I thought it cared about was just the format. I believe there is an underlying JDBC thing that stops this from happening. Otherwise it wouldn't be an issue.
What makes me come to this conclusion is that, when I do a SQL Server sub query, and grab a the date in the same format from a column in the SQL Server DB I'm working with, it works find. EX: Replace that date you see in this post with SET @StartTime = SELECT MAX(StartTime) as StartTime FROM [UICTransfer_Archive].[ETC.].[StageTable]; (Still the same format but trying to do this with that date retrieved or created outside SQL Server, its proving to be a pain)... I'll check out what you mentioned at work tomorrow and see what I come up with. I'll respond with results or questions after I give it a shot.
8 years ago
I have a date which is being stored as a String in an Oracle Database. I need to extract this value in my Java program (okay that is fine), but once it is in my Java program, how do I convert it to a DATE to be used in a SQL Server script for date comparisons?

I have an example below:

Oracle String: 2011/04/24 12:26:53

Format it needs to be to be used by SQL Server (Same format): 2011/04/24 12:26:53


ISSUE:

Retrieve String-Date from Oracle and convert it to a date type with the same format. (So SQL Server won't throw an error).


I am in need of a real example with a great explanation. I have looked online and have seen nothing that I can put together mentally in order to accomplish this while still keeping the HH:MI:SS: (I do also have milliseconds) Not shown here but it would help...



8 years ago
Thanks for the response. If I was to go with taking out the DECLARE block, would I just simply declare (let's say... @DateEnd) as a variable in my Java program and use it somehow? It would need to be dynamic based off the last hour processed instead of statically holding a date/time. The reason I ask is because those SQL Server variables are being used to read from the table and are incremented 60 minutes every time it loops through. If I was to insert a question mark and setTimeStamp(), how could I dynamically set it and have it incremented for each iteration if that were the case?

Your example is very interesting and will likely be my solution from how it sounds if certain things can happen by doing it like this.

Thanks again Greg.
I am connecting to two databases ultimately. (SQL Server and Oracle). Inside SQL Server I have one staging table where I hold multi-million records. My job is to read from it through a Java program. Inside the Java program, I will call a stored procedure in Oracle which will validate the data record by record (per hourly batch (continuous)) and insert the records that I need.
To read data from SQL Server hourly have the first script below which is on the Java side. The method below that is the getMaxLastHour() which selects the last hour proceessed from a Marker table I have in Oracle.

ISSUE: DATE/TIME --- I am not sure which data types to use in Java and also Oracle. I chose DATE. The problem here is that I can't get it to work. I return the last hour from Oracle and insert it into my SQL Server script so it knows where to resume processing. The Datatypes aren't matching up somewhere and I have no idea how to fix this.

Thank you for your help.


Go through a SQL Server table and grab data from it in hourly batches until there isn't any more data left to retrieve.



Get Last Hour Processed
Thank you for the link. I'm downloading it now and reading a bit about it.

Let me mention though that, when I read this data hourly, I need to go through that hourly batch and pass each record as an argument to another method so a procedure I wrote in Oracle can validate it. Do you have any advice on this?
8 years ago
I need to read data from SQL Server through a Java Progam and I need to read this data hourly (continuously) until there is no more data to grab. I am having a very difficult time learning how to do this... The code currently works. I just don't know how to loop through 'hourly'. In order to get the full date (and time) I needed to identify it as a String when retrieving it from the result set (DateEnd, DateStart, PlacementTime).
Can someone please give me some solid advice with some good examples. Thank you all.


The Code


8 years ago
Based off of your response, I put an example together. In this scenario, how would the Class.forName() be used. (if it would be at all in this case). I'm just trying to understand this and the exact case it would be used. You did great explaining it but I'm still lost in terms of the benefit and when I'd use it. Thank you.

With a base example, give or take what is actually listed in my sample below, when would I use Class.forName()?
9 years ago
Thank you for your response. That cleared my example up for me.
Generally though, would I want to use Class.forName() in any other case?
9 years ago
Can someone please explain to me what the below line of code is doing. I understand that by calling Class.forName(we are initializing everything that is static in that class). I may be a little off saying that but I still don't get the general's of it. Also the exact example below.

Details are great! Thanks to anyone that is willing to give some detailed input on this.

Class.forName("oracle.jdbc.driver.OracleDriver");
9 years ago