Usage of JSTL
Hi all,
I am using JSTL SQL tags for populating some form elements in my JSP. It is noted that it should not be used SQL tags for performance or some thing else. I found that its very easy way to populating the elements. My doubt is why dont I have to use SQL tags. Please anybody clearify my doubt.
thanks in advance
Prasad
Using the SQL tags is not a good idea for several reasons.
Number one among them in my book is the fact that you are linking your display (JSP) with how your data is stored. If you change databases - you have to change the JSP. If you change table formats - you have to change your JSP. If you change to storage in XML files, or some other storage system - you have to change your JSP.
But, if you move your data access into a Java Bean, and that Java Bean handles the SQL then, when you change how the data is stored, the bean may change but the JSP remains the same, no edits.
Additional benefits of moving SQL out of the JSP and into JavaBeans include the ability to test your data access system on a normal java system - no JSP server required, which makes development, testing, and re-structuring quicker.
Another one is that the SQL tags can complicate the JSP and make it much more complex than it needs to be when using other JSTL, EL, and Java Beans.
Similar Messages
-
How to display images and information
how to display images and information(e.g. like questions) on a jsp page that stored in a database
Look As far as i can see....
Utlimately every file could be expressed as a bytes buffer.
so say if you have a bean called Choice Bean which is expressed as
public class ChoiceBean{
private String choiceid;
private String choicedesc;
private byte image[];
public void setChoiceId(String choiceid){
this.choiceid = choiceid;
public String getChoiceId(){
return this.choiceid;
public void setChoiceDesc(String choicedesc){
this.choicedesc = choicedesc;
public String getChoiceDesc(){
return this.choicedesc;
public void setImage(byte image[]){
this.image = image;
public byte[] getImage(){
return this.image;
}QuestionList.java:
===============
public class QuestionList{
private List<ChoiceBean> choicelist;
/*Other member variable declarations*/
public List<ChoiceBean> getChoiceList(){
/*Custom code where you may build the list by querying the DA layer*/
return this.choicelist;
public int search(String choiceid){
int index = -1;
for(int i =0 ; i < this.choicelist.size() ; i++){
ChoiceBean cb = this.choicelist.get(i);
if(cb.getChoiceId().equals(choiceid)){
index = i;
break;
return index;
/* Other member method declarations */
}and you are retreving List<ChoiceBean> from DB using your query & have created a session attribute / <jsp:useBean> named ChoiceList
NOTE: sometimes your application server can go out of bounds as you are consuming a lot of memory by creating an arraylist object.
use the following methodology to display images & choices
sample.jsp:
=========
<jsp:useBean id="QuestionList" class="com.qpa.dao.QuestionList" scope="session"/>
<TABLE>
<%
/* QuestionList.getChoiceList() is a method which fetches data from the DB & returns it in form of List<ChoiceBean> */
List<ChoiceBean> choicelist = QuestionList.getChoiceList();
for(int i =0 ; i < choicelist.size() ; i++){
%>
<TR>
<TD><%!=choicelist.get(i).getChoiceId()%></TD>
<!-- calling servlet which renders an images in JPG format based upon given choiceid(unique field) -->
<TD><IMAGE src="ImageServlet?choiceid=<%!=choicelist.get(i).getChoiceId()%>"/> </TD>
<TD><%!=choicelist.get(i).getChoiceDesc()%></TD>
</TR>
<%
%>
</TABLE>
<%
session.remove("QuestionList");
%>
NOTE: usage of JSTL or any other custom built tag-libraries makes life more simpler in the following case
ImageServlet.java:
===============
public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
byte buffer[] = null;
HttpSession session = request.getSession(false);
/*getting the QuestionList from the session*/
QuestionList ql = null;
String choiceid = new String("");
try{
choiceid = request.getParameter("choiceid");
/*getting the QuestionList from the session*/
ql = (QuestionList) session.getAttribute("QuestionList");
} catch(Exception exp){
if(choiceid.equals("") == false && ql != null ){
List<ChoiceBean> clist = QuestionList.getChoiceList();
assuming that you have created a serach method which searches the entire choice list and would give you
the index of that object which is being refered by unique choiceid and returns -1 if not found
int index = QuestionList.search(choiceid);
if(index != -1){
ChoiceBean cb = clist.get(index);
buffer = cb.getImage();
if(buffer != null){
// assuming that we have stored images in JPEG format only
JPEGImageDecoder decoder = JPEGCodec.createJPEGDecoder(new ByteArrayInputStream(buffer));
BufferedImage image =decoder.decodeAsBufferedImage();
response.setContentType("image/jpeg");
// Send back image
ServletOutputStream sos = response.getOutputStream();
JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(sos);
encoder.encode(image);
} else {
response.setContentType("text/html");
response.getWriter().println("<b>Image data not found</b>");
}However,i still feel there are few loopholes with this approach where Application Server can eat up a lot of heap space which may result in outofmemorybound exception.
Hope this might help :)
REGARDS,
RaHuL -
Hello,
When we declare any bean on jsp using jsp:useBean i read that we can use that bean either in scriptlets or in expressions on jsp.
Im not clear about the same when we create any variable using JSTL like <c:set var="jspBean" value="myname"/>
as i know EL variables cannot be used in scriptlets or expressions, can they be used only in JSTL tags involving EL or we can use it any where.
Also, can we use JSTL in between some html formatting tags like <div> , <table>, <span> etc like :
<div <c:if test="${jspBean == 'myname'}"> style="width:9px;"</c:if> >
some text
</div>
If there is any nice tutorial/notes that shows the usage of EL, please let me know.
Please help me with my above questionsBest way to learn is to experiment :-)
Originally ${expr} only worked within specifically written tags.
Since JSP2.0, ${expr} can be used anywhere that you can use <%= expr %> - they are now both runtime expressions evaluated by the container (eg Tomcat 5)
Also, can we use JSTL in between some html formatting tags like <div> , <table>, <span> etc like :Yes. It will evaluate at runtime, and produce an HTML page to send to the client. The EL/JSTL gets evaluated on the server, the client never sees the if statement.
I would recommend reading the JSTL specification: http://java.sun.com/products/jsp/jstl/reference/api/index.html.
Cheers,
evnafets -
Hi, I have an application (on Glassfish 2.1.1) that seems like has one memory leak. I took a heap dump and i found an object (of class org.apache.taglibs.standard.lang.jstl.ELEvaluator) that consumes almost 900 Mb. The memory is allocated by the static field sCachedExpressionStrings. Viewing the documentation of apache taglibs, I found that this field is marked as static, and seems that the GC cannot liberate the space.
I need help, because this problem is in production environment.
Someone knows if some configuration exists for resolve this problem?
Regardsuser5343236 wrote:
I'm not entirely sure what usage causes it, but the same thing happened to us. I had a website that suffered from a heap growing by nearly 100MB per hour due to this. Looking at the heap dump revealed millions of ELEvaluator char[]s taking up all the space.
This JSTL memory leak bug exists even in the glassfish.jstl_1.2.0.1.jar that is packaged with the current version of JDev (11.1.1.4.0). Note that the compile time on the classes inside the JAR are dated earlier than the posts on this bugzilla thread that actually talk about a fix: https://issues.apache.org/bugzilla/show_bug.cgi?id=31789
The fix they talk about is still relevant relevant to JSTl 1.2 even though the discussion is based on 1.0.6, because the ELEvaluator and related classes didn't change much if at all. You can download the source for it and fix the problem based on the 31789.patch attached to that bugzilla report. Hope this helps others that stumble into the problem.Okay, you seem to have put a decent amount of investigation time into this; well done. Perhaps a new bug report is in order then? Although it doesn't seem that the people at Apache put too much development time into their Java APIs anymore. -
Jstl tags to display System date.
Hi there,
Please let me know how to how to display system date on jsp page using jstl.
I dont know much about jstl, and i was till now using java code in jsp instead of jstl.
Since using java in jsp is considered a bad programing these days, I dont want to use java
to display the date.
Can anyone help me switch to jstl tags.
Please help me with the date issue.[This will help you|http://java.sun.com/products/jsp/jstl/1.1/docs/tlddocs/index.html] learn what JSTL tags are available. Once you get that it should be relatively easy to figure out what you nee. If you have questions on a particular tag then a [Google search almost always|http://www.google.com/search?q=jstl+fmt%3AformatDate] brings up example usage.
-
I am new to jstl and I wrote the code for editing the information and i want the visible checkbox is checked if in the database it is visible or not checked in the checkbox if it is invisible but not working help me guys
<div>
<span class="label">Visible:</span>
<input type="checkbox" name="visible"
<c:if test="${ad.visible}">value="checked" </c:if>>
</div>http://www.w3schools.com/tags/tag_input.asp
<input type="checkbox" name="visible"
<c:if test="${ad.visible}">checked="checked" </c:if>> -
Problem with Firefox and very heavy memory usage
For several releases now, Firefox has been particularly heavy on memory usage. With its most recent version, with a single browser instance and only one tab, Firefox consumes more memory that any other application running on my Windows PC. The memory footprint grows significantly as I open additional tabs, getting to almost 1GB when there are 7 or 8 tabs open. This is as true with no extensions or pluggins, and with the usual set, (firebug, fire cookie, fireshot, XMarks). Right now, with 2 tabs, the memory is at 217,128K and climbing, CPU is between 0.2 and 1.5%.
I have read dozens of threads providing "helpful" suggestions, and tried any that seem reasonable. But like most others who experience Firebug's memory problems, none address the issue.
Firefox is an excellent tool for web developers, and I rely on it heavily, but have now resorted to using Chrome as the default and only open Firefox when I must, in order to test or debug a page.
Is there no hope of resolving this problem? So far, from responses to other similar threads, the response has been to deny any responsibility and blame extensions and/or pluggins. This is not helpful and not accurate. Will Firefox accept ownership for this problem and try to address it properly, or must we continue to suffer for your failings?55%, it's still 1.6Gb....there shouldn't be a problem scanning something that it says will take up 300Mb, then actually only takes up 70Mb.
And not wrong, it obviously isn't releasing the memory when other applications need it because it doesn't, I have to close PS before it will release it. Yes, it probably is supposed to release it, but it isn't.
Thank you for your answer (even if it did appear to me to be a bit rude/shouty, perhaps something more polite than "Wrong!" next time) but I'm sitting at my computer, and I can see what is using how much memory and when, you can't. -
Problem with scanning and memory usage
I'm running PS CS3 on Vista Home Premium, 1.86Ghz Intel core 2 processor, and 4GB RAM.
I realise Vista only sees 3.3GB of this RAM, and I know Vista uses about 1GB all the time.
Question:
While running PS, and only PS, with no files open, I have 2GB of RAM, why will PS not let me scan a file that it says will take up 300Mb?
200Mb is about the limit that it will let me scan, but even then, the actual end product ends up being less than 100Mb. (around 70mb in most cases)I'm using a Dell AIO A920, latest drivers etc, and PS is set to use all avaliable RAM.
Not only will it not let me scan, once a file I've opened has used up "x" amount of RAM, even if I then close that file, "x" amount of RAM will STILL be unavaliable. This means if I scan something, I have to save it, close PS, then open it again before I can scan anything else.
Surely this isn't normal. Or am I being stupid and missing something obvious?
I've also monitored the memory usage during scanning using task manager and various other things, it hardly goes up at all, then shoots up to 70-80% once the 70ishMb file is loaded. Something is up because if that were true, I'd actually only have 1Gb of RAM, and running Vista would be nearly impossible.
It's not a Vista thing either as I had this problem when I had XP. In fact it was worse then, I could hardly scan anything, had to be very low resolution.
Thanks in advance for any help55%, it's still 1.6Gb....there shouldn't be a problem scanning something that it says will take up 300Mb, then actually only takes up 70Mb.
And not wrong, it obviously isn't releasing the memory when other applications need it because it doesn't, I have to close PS before it will release it. Yes, it probably is supposed to release it, but it isn't.
Thank you for your answer (even if it did appear to me to be a bit rude/shouty, perhaps something more polite than "Wrong!" next time) but I'm sitting at my computer, and I can see what is using how much memory and when, you can't. -
Problem with JTree and memory usage
I have problem with the JTree when memory usage is over the phisical memory( I have 512MB).
I use JTree to display very large data about structure organization of big company. It is working fine until memory usage is over the phisical memory - then some of nodes are not visible.
I hope somebody has an idea about this problem.55%, it's still 1.6Gb....there shouldn't be a problem scanning something that it says will take up 300Mb, then actually only takes up 70Mb.
And not wrong, it obviously isn't releasing the memory when other applications need it because it doesn't, I have to close PS before it will release it. Yes, it probably is supposed to release it, but it isn't.
Thank you for your answer (even if it did appear to me to be a bit rude/shouty, perhaps something more polite than "Wrong!" next time) but I'm sitting at my computer, and I can see what is using how much memory and when, you can't. -
I reset my cellular data usage every month at the beginning of my billing period so that I can keep track of how much data I am using thru out the month. I do not have the unlimited data plan and have gone over a few times. It's usually the last couple days of my billing cycle and I am charged $10 for an extra gig which I barely use 10% of before my usage is restarted for new billing cycle. FYI, they do not carry the remainder of the unused gig that you purchase for $10 which I disagree with. But have accepted. Lol Moving on.
I have two questions. One possibly being answered by the other. 1. Is cellular data used when I sync to iTunes on my home computer to load songs onto my iPhone from my iTunes library(songs that already exist)? 2. What causes the cellular data usage readings in iPhone settings/general/usage/cellular usage to decrease if my last reset has not changed? It is close to end of my billing cycle and I have been keeping close eye. Earlier today it read around 180mb sent/1.2gb received. Now it reads 90mb sent/980 mb recieved. My last reset date reads the same as before. I don't know if my sync and music management had anything to do with the decrease but i didn't notice the decrease until after I had connected to iTunes and loaded music. I should also mention that a 700mb app automatically loaded itself to my phone during the sync process. Is cellular data used at all during any kind of sync /iPhone/iTunes management? Is the cellular data usage reading under iPhone settings a reliable source to keep track of monthly data usage? Guess turned out to be more than two questions but all related. Thanks in advance for any help you can offer me. It is information I find valuable. Sorry for the book long question.Is cellular data used at all during any kind of sync /iPhone/iTunes management? Is the cellular data usage reading under iPhone settings a reliable source to keep track of monthly data usage?
1) No.
2) It does provide an estimated usage, but it's not accurate. For accurate determination, you should check the remaining/used MBs from the carrier (most of the carriers provide this service for free). -
Background: My home does not have access to landline internet and I am relying on a Verizon Jetpack device rather than satellite cable for internet access. Within my JetPack wireless network I have several devices connected, iPADs, PC’s, printer, etc. (up to 5 devices can be connected with my system). Recently, I had one device within my immediate wireless network that I needed to transfer data via FTP to another local device within my immediate network. The receiving device FTP’d data from device (198.168.1.42) to local IP (address 192.168.1.2). To understand the data path a Trace rout for this transfer is 198.168.1.42 (source) to 198.168.1.1 (Jetpack) to 192.168.1.2 (receiver). Note that the VZW network ((cloud)/4G network) was NOT used in this transfer nor was any VZW bandwidth used for this transfer (of course less the typical overhead status/maintenance communications that happen regardless). Use of the VZW bandwidth would be something like downloading a movie from Netflix, (transferring data from a remote site, through the VZW network, into the Jetpack and to the target device). I also understand if ones devices have auto SW updates that would also go against the usage as well. I get that. My understanding of my usage billing is based data transfer across the VZW network.
Now to the problem: To my surprise I was quite substantially charged for the “internal” direct transfer of this data although I didn’t use the VZW network at all. This does not seem to be right, and doesn’t make much sense to me. Usage is should be based on the VZW network not a local Wi-Fi. In this case, Verizon actually gets free money from me without any use of or impact to the VZW network. Basically this is a VERY expensive rental for the jetpack device, which I bought anyway. Considering this, I am also charged each time I print locally. Dive into this further, I am also interested in knowing what is the overhead (non-data) communications between the jetpack router and devices and how much does that add up to over time?
Once I realized I was getting socked in bandwidth, as a temp solution I found an old Wi-Fi router, created a separate Wi-Fi network off the Jetpack, but the billing damage was already done. Switching each device back and forth to FTP and print is a hassle and there should be no reason the existing hardware couldn’t handle this and charges aligned with VSW usage. Is purposely intended by Verizon? Is this charging correct? And can I get some help with this?
Logically, usage should be based on VZW network usage not internal transfers. All transfers between IP addresses 192.168 are by default internal. Any data that needs to leave the internal network are translated in to the dynamic IP addresses established by the VZW network. That should be very easily detected for usage. In the very least, this fact needs to be clearly identified and clarified to users of the Jetpack. How would one use a local network and not get socked with usage charges? Can one set up a Wi-Fi network with another router, hardwire directly from the router to the Jetpack so that only data to and from the VZW network is billed? I might be able to figure out how to have the jetpack powered on but disable the VZW connection, but I don’t want to experiment and find out that the internal transfers are being logged and the log sent after the fact anyway once I connect…. A reasonable solution should be that users be able to use the router functions of the Jetpack (since one has to buy the device anyway) and only be billed for VZW usage.
Your help in this would be greatly appreciated. Thanksi had one mac and spilt water on it, the motherboard fried so i had to buy a used one...being in school and all. it is a MC375lla
Model Name:
MacBook Pro
Model Identifier:
MacBookPro7,1
Processor Name:
Intel Core 2 Duo
Processor Speed:
2.66 GHz
Number of Processors:
1
Total Number of Cores:
2
L2 Cache:
3 MB
Memory:
8 GB
Bus Speed:
1.07 GHz
Boot ROM Version:
MBP71.0039.B0E
SMC Version (system):
1.62f7
Hardware UUID:
A802DE22-1E57-5509-93C5-27CEF01377B7
Sudden Motion Sensor:
State:
Enabled
i do not have a backup of it, so i am thinking about replacing my old hard drive from the water damaged into this one, not even sure if that would work, but it did not seem to be damaged, as i recovered all the files i wanted off of it to put onto this mbp
the previous owner didnt have it set to boot, they had all their settings left on it and tried to edit all the names on it, had a bunch of server info and printers etc crap on it. i do not believe he edited the terminal system though--he doesnt seem to terribly bright(if thats possible)
tbh i hate lion compared to the old one i had, this one has so many more issues-overheating,fan noise, cd dvd noise
if you need screenshots or data of anything else as away
[problem is i do not want to start from scratch if there is a chance of fixing it, this one did not come with disks or anything like my first. so i dont even know if i could, and how it sets now i am basically starting from scratch, because now all my apps are reset but working, i am hoping to get my data back somehow though, i lost all of my bookmarks and editing all my apps and setting again would be a pain -
High memory usage when many tabs are open (and closed)
When I open Firefox the memory usage is about 70-100 MB RAM. When I'm working with Firefox I often open 15-20 tabs at once, then I close them and open others. Memory usage increaes up to 450 - 500 MB RAM. After closing the tabs the usage usually decreases, but after sometime. It starts decreasing very slow and never comes back to the level from the beginning. After few hours of work Firefox uses about 400 MB RAM even if one tab is open. First I thought it's because of my plugins (Firebug, Speed Dial, Adlock Plus) but I've checked it and it's not. I reinstalled Firefox but the problem occurs as well. I'm not sure if it's normal. Could you help me, please?
Hi,
Not an exact answer but please [http://kb.mozillazine.org/Reducing_memory_usage_(Firefox) see this.] The KB article ponders through various general situations which may or may not be applicable to specific instances but nevertheless could be helpful.
Useful links:
[https://support.mozilla.com/en-US/kb/Options%20window All about Tools > Options]
[http://kb.mozillazine.org/About:config Going beyond Tools > Options - about:config]
[http://kb.mozillazine.org/About:config_entries about:config Entries]
[https://addons.mozilla.org/en-US/firefox/addon/whats-that-preference/ What's That Preference? add-on] - Quickly decode about:config entries - After installation, go inside about:config, right-click any preference, enable (tick) MozillaZine Results to Panel and again right-click a pref and choose MozillaZine Reference to begin with.
[https://support.mozilla.com/en-US/kb/Keyboard%20shortcuts Keyboard Shortcuts]
[http://kb.mozillazine.org/Profile_folder_-_Firefox Firefox Profile Folder & Files]
[https://support.mozilla.com/en-US/kb/Safe%20Mode Safe Mode]
[http://kb.mozillazine.org/Problematic_extensions Problematic Extensions/Add-ons]
[https://support.mozilla.com/en-US/kb/Troubleshooting%20extensions%20and%20themes Troubleshooting Extensions and Themes] -
Hi
I am working in a sharepoint migration project. We have migrated one SharePoint project from moss2007 to sp2013. Issue is when we are clicking on Popularity trend > usage report, it is throwing an error.
Issue: The data was not being processed to EVENT STORE folder which was present under the
Analytics_GUID folder. Also data was not present in the Analytical Store database.
In log viewer I have found the bellow error.
HIGH -
SearchServiceApplicationProxy::GetAnalyticsEventTypeDefinitions--Error occured: System.ServiceModel.Security.MessageSecurityException: An unsecured or incorrectly
secured fault was received from the other party.
UNEXPECTED - System.ServiceModel.FaultException`1[[System.ServiceModel.ExceptionDetail,
System.ServiceModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]: We're sorry, we weren't able to complete the operation, please try again in a few minutes.
HIGH - Getting Error Message for Exception System.Web.HttpUnhandledException
(0x80004005): Exception of type 'System.Web.HttpUnhandledException' was thrown. ---> System.ServiceModel.Security.MessageSecurityException: An unsecured or incorrectly secured fault was received from the other party.
CRITICAL - A failure was reported when trying to invoke a service application:
EndpointFailure Process Name: w3wp Process ID: 13960 AppDomain Name: /LM/W3SVC/767692721/ROOT-1-130480636828071139 AppDomain ID: 2 Service Application Uri: urn:schemas-microsoft-
UNEXPECTED - Could not retrieve analytics event definitions for
https://XXX System.ServiceModel.FaultException`1[System.ServiceModel.ExceptionDetail]: We're sorry, we weren't able to complete the operation, please try again in a few minutes.
UNEXPECTED - System.ServiceModel.FaultException`1[[System.ServiceModel.ExceptionDetail,
System.ServiceModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]: We're sorry, we weren't able to complete the operation, please try again in a few minutes.
I have verified few things in server which are mentioned below
Two timer jobs (Microsoft SharePoint Foundation Usage Data Processing, Microsoft SharePoint Foundation Usage Data Import) are running fine.
APPFabric Caching service has been started.
Analytics_GUID folder has been
shared with
WSS_ADMIN_WPG and WSS_WPG and Read/Write access was granted
.usage files are getting created and also the temporary(.tmp) file has been created.
uasage logging database for uasage data being transported. The data is available.
Please provide pointers on what needs to be done.Hi Nabhendu,
According to your description, my understanding is that you could not use popularity trend after you migrated SharePoint 2007 to SharePoint 2013.
In SharePoint 2013, the analytics functionality is a part of the search component. There is an article for troubleshooting SharePoint 2013 Web Analytics, please take a look at:
Troubleshooting SharePoint 2013 Web Analytics
http://blog.fpweb.net/troubleshooting-sharepoint-2013-web-analytics/#.U8NyA_kabp4
I hope this helps.
Thanks,
Wendy
Wendy Li
TechNet Community Support -
Memory usage of excel stays high after Macro is executed and excel crashes after trying to close it
Hi,
I'm trying to resolve an issue with an excel based tool. The macros retrieve data from an Oracle database and do calculations with the data. They also open and write into files in the same directory. The macros all run and finish the calculations. I can
continue to use and modify the sheet. I can also close the workbook, however excel memory usage I see in the windows Task manager stays elevated.If I close Excel it says: Excel stopped working and then it tries to recover information...
I assume something in the macro did not finish properly and memory was not released. I would like to check what is still open (connection, stream or any other object) when I close the workbook I would like to have a list of all still used memory. Is there
a possibility to do so.
Here the code I'm using, its reduced to functions which open something. Functions
get_v_tools() and get_change_tools() are same as get_client_positions().
Public conODBC As New ADODB.Connection
Public myPath As String
Sub get_positions()
Dim Src As range, dst As range
Dim lastRow As Integer
Dim myPath As String
lastRow = Sheets("SQL_DATA").Cells(Sheets("SQL_DATA").rows.Count, "A").End(xlUp).Row
Sheets("SQL_DATA").range("A2:AD" & lastRow + 1).ClearContents
Sheets("SQL_DATA").range("AG2:BE" & lastRow + 2).ClearContents
Sheets("SQL_DATA").range("AE3:AF" & lastRow + 2).ClearContents
k = Sheets("ToolsList").Cells(Sheets("ToolsList").rows.Count, "A").End(xlUp).Row + 1
Sheets("ToolsList").range("A2:M" & k).ClearContents
'open connection
Call open_connection
lastRow = Sheets("SQL_DATA").Cells(Sheets("SQL_DATA").rows.Count, "A").End(xlUp).Row
If lastRow < 2 Then GoTo ErrorHandling
'copy bs price check multiplications
Set Src = Sheets("SQL_DATA").range("AE2:AF2")
Set dst = Worksheets("SQL_DATA").range("AE2").Resize(lastRow - 1, Src.columns.Count)
dst.Formula = Src.Formula
On Error GoTo ErrorHandling
'new prices are calculated
newPrice_calculate (lastRow)
Calculate
myPath = ThisWorkbook.Path
'Refresh pivot table in Position Manager
Sheets("Position Manager").PivotTables("PivotTable3").ChangePivotCache ActiveWorkbook. _
PivotCaches.Create(SourceType:=xlDatabase, SourceData:= _
myPath & "\[Position_Manager_v1.0.xlsm]SQL_DATA!R1C2:R" & lastRow & "C31" _
, Version:=xlPivotTableVersion14)
ErrorHandling:
Set Src = Nothing
Set dst = Nothing
If conODBC.State <> 0 Then
conODBC.Close
End If
End Sub
Sub open_connection()
Dim sql_data, sql_data_change, sql_data_v As Variant
Dim wdth, TotalColumns, startRow As Integer
Dim rst As New ADODB.Recordset
Errorcode = 0
On Error GoTo ErrorHandling
Errorcode = 1
With conODBC
.Provider = "OraOLEDB.Oracle.1"
.ConnectionString = "Password=" & pswrd & "; Persist Security Info=True;User ID= " & UserName & "; Data Source=" & DataSource
.CursorLocation = adUseClient
.Open
.CommandTimeout = 300
End With
startRow = Sheets("SQL_DATA").Cells(Sheets("SQL_DATA").rows.Count, "A").End(xlUp).Row + 1
sql_data = get_client_positions(conODBC, rst)
wdth = UBound(sql_data, 1)
Sheets("SQL_DATA").range("A" & startRow & ":AA" & wdth + startRow - 1).Value = sql_data
'Run change tools instruments
startRow = Sheets("ToolsList").Cells(Sheets("ToolsList").rows.Count, "A").End(xlUp).Row + 1
sql_data_change = get_change_tools(conODBC, rst)
wdth = UBound(sql_data_change, 1)
Sheets("ToolsList").range("A" & startRow & ":M" & wdth + startRow - 1).Value _
= sql_data_change
'open SQL for V tools instruments
startRow = Sheets("ToolsList").Cells(Sheets("ToolsList").rows.Count, "A").End(xlUp).Row + 1
sql_data_v = get_v_tools(conODBC, rst)
wdth = UBound(sql_data_v, 1)
Sheets("ToolsList").range("A" & startRow & ":L" & startRow + wdth - 1).Value = sql_data_v
conODBC.Close
ErrorHandling:
If rst.State <> 0 Then
rst.Close
End If
Set rst = Nothing
End Sub
Private Function get_client_positions(conODBC As ADODB.Connection, rst_posi As ADODB.Recordset) As Variant
Dim sql_data As Variant
Dim objCommand As ADODB.Command
Dim sql As String
Dim records, TotalColumns As Integer
On Error GoTo ErrorHandling
Set objCommand = New ADODB.Command
sql = read_sql()
With objCommand
.ActiveConnection = conODBC 'connection for the commands
.CommandType = adCmdText
.CommandText = sql 'Sql statement from the function
.Prepared = True
.CommandTimeout = 600
End With
Set rst_posi = objCommand.Execute
TotalColumns = rst_posi.Fields.Count
records = rst_posi.RecordCount
ReDim sql_data(1 To records, 1 To TotalColumns)
If TotalColumns = 0 Or records = 0 Then GoTo ErrorHandling
If TotalColumns <> 27 Then GoTo ErrorHandling
If rst_posi.EOF Then GoTo ErrorHandling
l = 1
Do While Not rst_posi.EOF
For i = 0 To TotalColumns - 1
sql_data(l, i + 1) = rst_posi.Fields(i)
Next i
l = l + 1
rst_posi.MoveNext
Loop
ErrorHandling:
rst_posi.Close
Set rst_posi = Nothing
Set objCommand = Nothing
get_client_positions = sql_data
End Function
Private Function read_sql() As String
Dim sqlFile As String, sqlQuery, Line As String
Dim query_dt As String, client As String, account As String
Dim GRP_ID, GRP_SPLIT_ID As String
Dim fso, stream As Object
Set fso = CreateObject("Scripting.FileSystemObject")
client = Worksheets("Cover").range("C9").Value
query_dt = Sheets("Cover").range("C7").Value
GRP_ID = Sheets("Cover").range("C3").Value
GRP_SPLIT_ID = Sheets("Cover").range("C5").Value
account = Sheets("Cover").range("C11").Value
sqlFile = Sheets("Cover").range("C15").Value
Open sqlFile For Input As #1
Do Until EOF(1)
Line Input #1, Line
sqlQuery = sqlQuery & vbCrLf & Line
Loop
Close
' Replace placeholders in the SQL
sqlQuery = Replace(sqlQuery, "myClent", client)
sqlQuery = Replace(sqlQuery, "01/01/9999", query_dt)
sqlQuery = Replace(sqlQuery, "54747743", GRP_ID)
If GRP_SPLIT_ID <> "" Then
sqlQuery = Replace(sqlQuery, "7754843", GRP_SPLIT_ID)
Else
sqlQuery = Replace(sqlQuery, "AND POS.GRP_SPLIT_ID = 7754843", "")
End If
If account = "ZZ" Then
sqlQuery = Replace(sqlQuery, "AND AC.ACCNT_NAME = 'ZZ'", "")
Else
sqlQuery = Replace(sqlQuery, "ZZ", account)
End If
' Create a TextStream to check SQL Query
sql = sqlQuery
myPath = ThisWorkbook.Path
Set stream = fso.CreateTextFile(myPath & "\SQL\LastQuery.txt", True)
stream.Write sql
stream.Close
Set fso = Nothing
Set stream = Nothing
read_sql = sqlQuery
End FunctionThanks Starain,
that's what I did the last days and found that the problem is in the
newPrice_calculate (lastRow)
function. This function retrieves data (sets it as arrays) which was correctly pasted into the sheet, loops through all rows and does math/calendar calculations with cell values using an Add-In("Quantlib")
Public errorMessage as String
Sub newPrice_calculate(lastRow)
Dim Type() As Variant
Dim Id() As Variant
Dim Price() As Variant
Dim daysTo() As Variant
Dim fx() As Variant
Dim interest() As Variant
Dim ObjCalend as Variant
Dim newPrice as Variant
On Error GoTo Catch
interest = Sheets("SQL_DATA").range("V2:V" & lastRow).Value
Type = Sheets("SQL_DATA").range("L2:L" & lastRow).Value Id = Sheets("SQL_DATA").range("M2:M" & lastRow).Value Price = Sheets("SQL_DATA").range("T2:T" & lastRow).Value
daysTo = Sheets("SQL_DATA").range("K2:K" & lastRow).Value
fx = Sheets("SQL_DATA").range("U2:U" & lastRow).Value
qlError = 1
For i = 2 To lastRow
If (i, 1) = "LG" Then
'set something - nothing spectacular like
interest(i, 1) = 0
daysTo(i , 1) = 0
Else
adjTime = Sqr(daysTo(i, 1) / 365)
ObjCalend(i,1) =Application.Run("qlCalendarHolidaysList", _
"CalObj", ... , .... other input parameters)
If IsError(ObjCalend(i,1)) Then GoTo Catch
'other calendar calcs
newPrice(i,1) = Application.Run( 'quantLib calcs)
End If
Catch:
Select Case qlError
Case 1
errorMessage = errorMessage & " QuantLibXL Cal Error at: " & i & " " & vbNewLine & Err.Description
ObjCalend(i,1) (i, 1) = "N/A"
End Select
Next i
Sheets("SQL_DATA").range("AB2:AB" & lastRow).Value = newPrice
'Sheets("SQL_DATA").range("AA2:AA" & lastRow).Value = daysTo
' erase and set to nothing all arrays and objects
Erase Type
Erase id
Erase Price
Set newPrice = Nothing
Is there a possibility to clean everything in:
Private Sub Workbook_BeforeClose(Cancel As Boolean)
End Sub
Thanks in advance
Mark -
I have recently uncovered mysterious cellular usage on three different iPhones. I am a Verizon customer and discovered this by examining the cellular data use logs. What I found are a long series of mysterious data usage logs. I have visited the Genius Bar at my local Apple Store 3 times now to log notes and discuss the issue. It is being escalated.
The characterstics are as follows:
All my family phones have the appropriate IOS and hardware updates (verified by the GeniusBar at my local Apple Store).
This is occuring across three phones, which happen to all be iphone 5. Two are 5 and the other a new 5s. We do have one iphone 4 in the family but the issue (so far as I can tell), is not happening on it.
One iphone 5 has IOS 7, the other IOS 6. The new 5s has of course IOS 7.
Mysterious data use happens even while connected to wifi.
Each mysterious data use log entry is exactly 6 hours apart. For example: 2:18 AM, 8:18 AM, 2:18 PM, 8:18 PM, 2:18 AM ... etc. It cycles AM and PM, same times, for a day to many days until some condition causes it to change (evolve).
The times evolve. One day it could be cycling through at one time series, then it changes to another time sequence and continues until the next condition.
The data usage is anywhere from a few K to many MB. The largest I've seen is over 100 MB.
The logs clearly show these usages are not due to human interaction. It is a program.
If cellular connection is used frequently (by the owner), the pattern is hard to pick out. Luckily, my family member is very good about only using wifi whenever possible, so these mysterious use patterns are easy to pick out.
Verizon allows access to 90 days worth of data logs, so I downloaded and analyzed them. This has been happening for at least 90 days. I have found 298 instances of mysterious use out of 500 total connections to cellular. A total of 3.5 GB of mysterious cellular data has been recorded as used in that 90 days by this phone alone. Only .6 GB of the total cellular data use is legitimate, meaning by the person.
This issue is occuring across three different phones. Two are iPhone 5, and the third is a recently purchased iPhone 5s. The 5s I have not touched beyone the basic startup. I have left it alone on a desk for 3 days, and looking at the logs, the mysterious data use in the same pattern is occuring.
So ... I am speaking to both sides, Verizon and Apple to get answers. Verizon puts their wall up at data usage. It doesn't matter how it is being used, you simply need to pay for it. Yes, the evidence I have gathered is getting closer to someting on Verizon's end.
Before pressing in that direction, I am hoping someone reading this may recognize this issue as a possible iPhone 5 issue ... OR ... you, right now, go look at your data usage logs available through your carrier's web account, and see if you can pick out a pattern of mysterious use. Look especially at the early morning instances when you are most likely sleeping.
I am hoping this is a simple issue that has a quick resolution. I'm looking for the "ooohhh, I see that now ..." But I am starting to think this might be much bigger, but the fact is, most customers rarely or never look at their data usage details, much less discover mysterious use patterns.
The final interesting (maybe frightening part) thing about all this is that I discovered while talking to Verizon ... they do not divulge which direction the data is going. This goes for any use, mysterious or legitimate. Is cellular data coming to your phone, or leaving it? Is something pulling data from your phone? We know that it is possible to build malware apps, but the catch with my issue is that it is also happening on a brand new iphone 5s with nothing downloaded to it.
Thanks for your timeThanks for the replies. It took a while not hearing anything so thought I was alone. I have done many of the suggestions already. The key here is that it occurs on both phones with apps, and phones still packaged in a box.
A Genius Bar supervisor also checked his Verizon data usage log and found the same 6 hour incremental use. Suprisingly, he did not express much intrigue over that. Maybe he did, but did not show it.
I think the 6 hour incremental usage is the main issue here. I spoke with Verizon (again) and they confirmed that all they do is log exactly when the phone connected to the tower and used data. The time it records is when the usage started. I also found out that the time recorded is GMT.
What is using data, unsolicited, every 6 hours?
Why does it change?
Why does it only happen on the iPhone 5 series and not the 4?
Since no one from Apple seems to be chiming in on this, and I have not received the promised calls from Apple tech support that the Genius Bar staff said I was suppose to receive, it is starting to feel like something is being swept under the rug.
I woke up the other day with another thought ... What application would use such large amounts of data? Well ... music, video, sound and pictures of course. Well ... what would someone set automatically that is of any use to them? hmmm ... video, pictures, sound. Is the iPhone 5 succeptible to snooping? Can an app be buried in the IOS that automatically turns on video and sound recording, and send it somewhere ... every 6 hours? Chilling. I noted that the smallest data usage is during the night when nothing is going on, then it peaks during the day. The Genius Bar tech and I looked at each other when I drew this sine wave graph on the log print outs during an appointment ...
Maybe you are looking for
-
Incorrect data value selected when clicking on slicer entry in Excel Services
We have uploaded various Excel 2013 files containing pivot tables to Sharepoint 2013 and viewed the pivot tables in a browser. The referenced pivot table data is normally a SSAS tabular model. This has been working fine for over 12 months apart from
-
I can't figure out what im doing wrong with my File I/O program lol
I'm new to the java language and was wondering if anybody could help me with the program i an writing. I don't quite understand file I/O but I've given it my best and I'm stuck. I'm supposed to write a program that will read in a file of student acad
-
In the top left on my screen where the back arrow button is to go back to previous webpages, there used to be a drop down arrow just to the right so I can see many of my previous web pages. Since installing Firefox 4.0.1, that arrow disappeared.
-
Facebook chat in OS X Messages shows numbers instead of names
Though I have used Facebook chat in iChat and now OS X's Messages programs for many years now with few issues (some disconnecting issues here and there but that's about it) The past few days I have encountered a problem that I can't figure out how to
-
Adobe Flash issues with camera
I use several web site video chats usually. Since installing Lion the Flash permissions screens are totally non-responsive. I am even unable to clear out of them by selecting Deny. Totally non-functional. Tried to download a newer version of Flas