Total Pageviews

2010/12/24

SchemaSpy Quick Start

Introduction
SchemaSpy is a Java-based tool (requires Java 5 or higher) that analyzes the metadata of a schema in a database and generates a visual representation of it in a browser-displayable format. It lets you click through the hierarchy of database tables via child and parent table relationships as represented by both HTML links and entity-relationship diagrams. It's also designed to help resolve the obtuse errors that a database sometimes gives related to failures due to constraints.

Running SchemaSpy
You run SchemaSpy from the command line: java -jar schemaSpy.jar -t dbType -db dbName [-s schema] -u user [-p password] -o outputDir
For further information, please check: http://schemaspy.sourceforge.net/

Execution Process
3. execute a command:
java -jar "C:\schemaSpy_5.0.0.jar" -dp "C:\ojdbc6.jar" -t orathin -db dev02 -s ap_tax -host 192.168.30.102 -port 1521 -u ap_tax -p taxtest -schemas AP_TAX -connprops "C:\schemaSpyGUI\properties\orathin.properties" -charset UTF-8 -o "C:\schemaSpyGUI\output" -norows -hq
4. check the output

java.lang.UnsatisfiedLinkError: no ocijdbc11 in java.library.path

Scenario
As I run SchemaSpy and use this command line:
java -jar "C:\schemaSpy_5.0.0.jar" -dp "C:\ojdbc6.jar" -t ora -db dev02 -s ap_tax -host 192.168.30.102 -port 1521 -u ap_tax -p taxtest -schemas AP_TAX -connprops "C:\schemaSpyGUI\properties\ora.properties" -charset UTF-8 -o "C:\schemaSpyGUI\output" -norows -hq

I got this error message:
 Failed to load driver [oracle.jdbc.driver.OracleDriver] from classpath [file:/C:/ojdbc6.jar]  
 Make sure the reported library (.dll/.lib/.so) from the following line can be  
 found by your PATH (or LIB*PATH) environment variable  
 java.lang.UnsatisfiedLinkError: no ocijdbc11 in java.library.path  
 at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1734)  
 at java.lang.Runtime.loadLibrary0(Runtime.java:823)  
 at java.lang.System.loadLibrary(System.java:1028)  
 at oracle.jdbc.driver.T2CConnection$1.run(T2CConnection.java:3535)  
 at java.security.AccessController.doPrivileged(Native Method)  
 at oracle.jdbc.driver.T2CConnection.loadNativeLibrary(T2CConnection.java:3531)  
 at oracle.jdbc.driver.T2CConnection.logon(T2CConnection.java:266)  
 at oracle.jdbc.driver.PhysicalConnection.(PhysicalConnection.java:536)  
 at oracle.jdbc.driver.T2CConnection.(T2CConnection.java:162)  
 at oracle.jdbc.driver.T2CDriverExtension.getConnection(T2CDriverExtension.java:53)  
 at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:521)  
 at net.sourceforge.schemaspy.SchemaAnalyzer.getConnection(SchemaAnalyzer.java:582)  
 at net.sourceforge.schemaspy.SchemaAnalyzer.analyze(SchemaAnalyzer.java:157)  
 at net.sourceforge.schemaspy.Main.main(Main.java:42) 

Root Cause
I assign wrong database type and connection property in command line.

Solution
Change database type from ora to orathin:
java -jar "C:\schemaSpy_5.0.0.jar" -dp "C:\ojdbc6.jar" -t orathin -db dev02 -s ap_tax -host 192.168.30.102 -port 1521 -u ap_tax -p taxtest -schemas AP_TAX -connprops "C:\schemaSpyGUI\properties\orathin.properties" -charset UTF-8 -o "C:\schemaSpyGUI\output" -norows -hq

2010/12/23

SQuirreL SQL Client Quick Start


Introduction
SQuirreL SQL Client is a graphical Java program that will allow you to view the structure of a JDBC compliant database, browse the data in tables, issue SQL commands etc

Prerequisite
1. download SQuirreL SQL Client from http://squirrel-sql.sourceforge.net/
2. download JDBC jar file, i.e. Oracle 11 JDBC jar file from http://www.oracle.com/technetwork/database/enterprise-edition/jdbc-112010-090769.html

Installation
1. use command line to execute jar file

2. It will pop up GUI window to install. Just do step by step

Click Next

Click Next

Click Next

Choose plug-ins if you need, and click next

Click Next

Launch SQuirreL SQL Client
1. Click squirrel-sql.bat (in windows platform) to launch this tool

2. Configure Jar file

3. Configure Database Connection

4. Connect to database

2010/12/22

11 tips for better code

1. keep methods short
2. never ever ever reuse a variable for different purpose
3. use self-descriptive variable and method names
4. define variables as close as possible to the place of their usage
5. no magic numbers
6. be friend with your language
7. don’t fight the convention
8. watch out for premature optimization
9. always refactor the code after you test it
10. don’t get sucked into overengineering
11. learn new things by prototyping

http://www.dzone.com/links/r/11_tips_for_better_code.html

2010/12/17

AutoPagerize for Chrome

AutoPagerize is a browser Extension for auto loading paginated web pages. AutoPagerize use in many web site, and provide efficiently web browsing.


2010/12/10

12 programming mistakes to avoid

Programming mistake No. 1: Playing it fast and loose
Programming mistake No. 2: Overcommitting to details
Programming mistake No. 3: Not simplifying control
Programming mistake No. 4: Delegating too much to frameworks
Programming mistake No. 5: Trusting the client
Programming mistake No. 6: Not trusting the client enough
Programming mistake No. 7: Relying too heavily on magic boxes
Programming mistake No. 8: Reinventing the wheel
Programming mistake No. 9: Opening up too much to the user
Programming mistake No. 10: Overdetermining the user experience
Programming mistake No. 11: Closing the source
Programming mistake No. 12: Assuming openness is a cure-all

http://www.dzone.com/links/r/12_programming_mistakes_to_avoid.html

2010/12/04

cloc - count line of code

Introduction
cloc counts blank lines, comment lines, and physical lines of source code in many programming languages. Given two versions of a code base, cloc can also compute changes in blank, comment, and source lines. It is written entirely in Perl with no dependencies outside the standard distribution of Perl v5.6 and higher (code from some external modules is embedded within cloc) and so is quite portable. cloc is known to run on many flavors of Linux, Mac OS X, AIX, Solaris, IRIX, z/OS, and Windows.


Usage
[command]cloc-1.53.exe --not-match-f=.*Test --by-file --skip-uniqueness --skip-win-hidden --csv --report-file=[output-file] [source folder]

[example]cloc-1.53.exe --not-match-f=.*Test --by-file --skip-uniqueness --skip-win-hidden --csv --report-file=nig_loc.csv "D:\work\FDC\0.svn\trunk\SDS\source code"

output file

2010/12/03

How to align JSF h:outputText text to right?

Original Way

But it doesn't work
What we need to do is to add div tag to enclose outputText tag, and define text-align in div tag

It works now....

2010/12/01

The value of attribute "itemLabel" associated with an element type "null" must not contain the '<' character.

Environment: JSF 2.0 on GlassFish V3

[Error Message]
The value of attribute "itemLabel" associated with an element type "null" must not contain the '<' character.

Source Code 

Root Cause
The problem results from the itemValue cannot accept < in xhtml page

Solution
Move selectItems value and label to managed bean
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
    //declare a List variable    
   public List compareList = new ArrayList();
 
    //declare a getter class
    public List getCompareList() {         
  compareList.clear();
  compareList.add(new SelectItem(">", ">"));
  compareList.add(new SelectItem("<", "<="));
  return compareList;     
 }

xhtml page should be updated to be like this:

Demo: