Category: Programming
Apostrophe in a SQL Query String
June 16th, 2009I was running into a problem with a SQL query string being terminated to soon. One of the variables I was using in the concatenation of the string contained an apostrophe. In order to handle this situation you have to put two apostrophes to escape the character in the string.
For example SELECT column1 FROM table WHERE column2='values's' needs to be SELECT column1 FROM table WHERE column2='values''s'.
The application I was writing used Jython. Jython is just Python implemented in Java. I have found working with strings in Jython to be very easy.
Here is the function I came up with to use on the variable before using it in the SQL query string.
def sqlApostrophes(strInput):
strOutput = strInput.replace("'","''")
return strOutput
Running Tom Cat on Windows 7
February 4th, 2009I was trying to get Tom Cat to start on Windows 7. When trying to start the service I would receive an error message stating the service could not start.
After some digging around on the internet the solution to the problem was to set the environment variables.
right click computer and choose properties.
click advanced system settings.
click environment variables.
under system variables click new.
input the variable name as JAVA_HOME and the value as the path to the root of the jdk directory.
Add another new system variable.
input the variable namee as PATH and the value as the path to the bin folder in the jdk directory.
i.e.
JAVA_HOME C:\Program Files\Java\jdk1.6.0_12
PATH C:\Program Files\Java\jdk1.6.0_12\bin
Featured Work on Inductive Automations Website
November 23rd, 2008One of my current projects at Sierra Nevada Brewing Co. has been featured in the newsletter for Inductive Automation. Inductive Automation makes the development tools we use to rapidly deploy system integration solutions. You can read the article about our use of Inductive Automation's products and see some screen shots of what we have created. Below is a link to the Sierra Nevada Brewing Co. interview and a picture of of the screen I created featured on Inductive Automations website.
Lock Workstation on Startup
November 13th, 2008Found it. I did not even need to write a script. Just put a shortcut to C:\Windows\System32\tsdiscon.exe in your startup folder.
I found this solution at this site: http://www.winhelponline.com/blog/how-to-automatically-login-to-windows-and-then-lock-the-workstation/
Here is another site if you do want to write a script in order to lock a remote workstation.
http://www.microsoft.com/technet/scriptcenter/resources/qanda/nov04/hey1115.mspx
Script Virtual PC Virtual Machines to start
November 13th, 2008Both my web server and exchange server are running on Microsoft Virtual PC. I was getting tired of having the start the servers manually when restarting the host. I did some searching on the internet and came up with a VB script to fix the problem.
Here it is:
Option Explicit
Dim WSHShell, WSHShell1, WSHShell2
'Now launch virtual machine
Set WSHShell = CreateObject("Wscript.Shell")
WSHShell.Run Chr(34) & "C:\Program Files (x86)\Microsoft Virtual PC\Virtual PC.exe"
WScript.Sleep(5000)
Set WSHShell1 = CreateObject("Wscript.Shell")
WSHShell1.Run Chr(34) & "C:\Virtual Machines\VM name1.vmc"
Set WSHShell2 = CreateObject("Wscript.Shell")
WSHShell2.Run Chr(34) & "C:\Virtual Machines\VM name2.vmc"
I just saved this to a .vbs file and put it in my startup folder. Now when I log in after a restart the VMs will startup automatically. Now I just need to edit the registry to auto logon and create script to lock my computer after logon. This should save me from having to login after a windows update installing in the night.
This webpage helped me out: http://www.tek-tips.com/viewthread.cfm?qid=1484499&page=7
There sleep syntax was not right so I changed it to WScript.Sleep(5000). Without the sleep I could not get the VMS to start.
