Friday, 8 May 2015

subclipse - saving or reusing your SVN repositories

So you want to reuse your list of SVN repositories in another WORKSPACE or in another install of eclipse.

If you use Subversive it is very easy to backup your SVN repositiories:

    This is done by simply going to File -> Export -> Select from General -> Preferences.
    Then on the next step you can tick from a list the preferences you want to export.
    In this list, SVN preferences and SVN repositories should be included.

I have found no way of doing this in Subclipse, so here is a manual method.
NB though it is a total copy, there is no way to just copy a limited set of SVN repositories.

    Navigate to the dir YOUR_WORKSPACE/.metadata/.plugins/org.tigris.subversion.subclipse.core       In there there is a file '.svnProviderState'
    This is a binary file but just copy this to the new WORKSPACE in the equivelent directory & that is it.

(Thanks to a colleague at work - Philip Lau for this)

Tuesday, 28 April 2015

oracle - listing locks & removing them

While logged in as sysadmin, SQL to list any locks on a particular table:
SELECT SID,SERIAL# 
FROM V$SESSION 
WHERE SID IN (SELECT SESSION_ID 
FROM DBA_DML_LOCKS 
WHERE NAME = 'SOME_TABLE_NAME');
SQL to remove a specific lock, using the values from the above SQL:
ALTER SYSTEM KILL SESSION 'SID,SERIALl#';

Thursday, 2 October 2014

Hibernate - annotation mappings and misleading SerializationException

Took me a few hours to get to the bottom of this.
I was getting the following Exception, which did not make sense as the deSerialization test passed OK.
I have a domain object that I had proved through a unit test that I could serialize & deserialize successfully.


My domain object contained the following object which if I removed then worked OK:


But tomcat & my integration test were both failing with the following Exception.


It turns out I had missed out an annotation, obvious really but I could not spot the error & the Exception was totally misleading. What had I missed? The '@manyToOne' annotation. Twit.

Tuesday, 15 April 2014

Eclipse & the error 'Specified VM install not found: type Standard VM, name'

Scenario:

  • I had a project that was previously building OK
  • At some point I upgraded the version of java
  • Came to rebuild the project and the Ant build was failing with the error popup
    • Specified VM install not found: type Standard VM, name
    • & it was referring to an old JDK that did not exist on my PC & was not referred to by eclipse with the list of installed JREs
  • I searched in the project for the JDK listed 'jdk1.6.0_26' 
    • No luck - could not find anythine
  • I deleted the project & reloaded it from SVN
    • Still No luck - I got the same error

After a bit of googling, I found this site http://www.javaworkspace.com/VMNotFound.do
I went for option '2' of edting the launch file in the directory simply renaming the JDK after stopping eclipse.
  • C:\projects\WORKSPACE\.metadata\.plugins\org.eclipse.debug.core\.launches
All sorted now thanks.

Tuesday, 8 April 2014

sqlserver 2012 installation - a few possible gotchas

I have just installed sqlserver 2012 on the same server as one using 2008.
All was good as for accessing through both Management Studios but I struggled to get the web applications to connect to the 2012 databases.

These are all probably standard SQLServer Gotchas but they all got me.

Gotchas:

  1. In the config I created a user 'sa' but this was disabled by default
    1. find the user, right click & go to properties
    2. click on 'Status' & select Enabled
  2. The database it self did not allow Sql Server authentication.
    1. Right click on the database server instance & select Properties
    2. click on Security
    3. Select the second option 'SQL Server & Windows Authentication'
  3. Port Configuration
    1. The default port for SQL server is 1433 so I needed to set up a different port for 2012
    2. Run up the 'SQL Server Configuration Manager'
    3. Inder the tab 'SQL Server Network Configuration' there will be two entries, one for the 2008 service & one for the 2012 service
    4. Select tge 2012 service
    5. select the TCP/IP protocal name & Right click & select Properties
    6. Select the 'IP Addresses' tab
    7. On mine the 'TCP Port' field was blank for all entries. I changed everyone to be 1533
Job done I can now connect with my user 'sa' using a standard conmection string but the new port number of 1533

Thursday, 19 December 2013

sqlServer Management Studio not remembering users & passwords

Since I had a new Windows build for my PC I have had the very annoying bug that SQLServer Management Studio would not remember the username & passwords for hosts.

The Workarounds tab here provides the solution, but is essence it is this:

Rename:
SQL Server Management Studio 2008 delete the file C:\Users\%username%\AppData\Roaming\Microsoft\Microsoft SQL Server\100\Tools\Shell\SqlStudio.bin

SQL Server Management Studio 2005 delete the file – same as above answer but the Vista path. C:\Users\%username%\AppData\Roaming \Microsoft\Microsoft SQL Server\90\Tools\Shell\mru.dat

Friday, 15 November 2013

Editing Excel XLSX files manually to change cell label names

We have an application that manipulates XLSX Excel files using the excellent Java Apache POI package

We have the need to deploy this application for lots of different customers & the labels used in the spreadsheets need to be customer specific. In our case the cell names are prefixed with the customer name say 'foo' & we need to alter them all to 'foo'

Now you could do this longhand in Excel but this is time comsuming & a major issue for us is that you are not actually renaming the cells in Excel, you are actually adding  an extra name to a cell.

So what to do.

1) Handily XLSX files are acxtually zip compressed files so firstly extract all the files using your favourite tool, for me I use 7zip 
2) run a command to search for all the files that contain the name you want to change

  •     find . | xargs grep -l foo 2> /dev/null

This will probably list 4 files:

  • ./docProps/app.xml
  • ./xl/charts/chart1.xml
  • ./xl/charts/chart2.xml
  • ./xl/workbook.xml 


3)Edit these files using your favourite editor. For the changes we want to make something like 'vi' or 'vim' is perfect.
4) If you are just changing names then one command will do it

  •     :1,$s/foo/bar/g

5)We also had a case where cells were duplicated for two customers 'foo' & 'bar' and we wanted to remove all the 'foo' tags. This was in the files 'app.xml' & 'workbook.xml' . Here care is needed. Excel creates these files as one long line with loads of XML tags.

6) So firstly you have to seperate the lines, For app.xml this is:

  • :1,$s/<\/vt:lpstr><vt:lpstr>/<\/vt:lpstr>\r<vt:lpstr>/g
    

    For workbook.xml, this two commands are needed:
  • :1,$s/<\/definedName><definedName name/<\/definedName>\r<definedName name/g
    
  • :1,$s/<definedNames><definedName name/<definedNames>\r<definedName name/g
    
7) You then delete the lines containing the string 'foo', but firstly count how many lines contain the string 'foo', so

  • :%s/foo//gn
Then delete the lines
  • :g/foo/d

8) In the case of app.xml two extra edits are required. See the XML below. This is a snippet of app.xml. In this example note the two numbers '87' & '93'. These both need decreasing by the numbers of lines you have deleted.Note I have formatted the XML below to make for easier reading

9) You now need to repackage this up using something like 7zip, but note the archive format must be 'zip' and the compression method must be 'DEFLATE'

Now go & enjoy.