Simple JSP JDBC Example
January 29, 2008 | Leave a Comment
I learned to program on Java, but have done little to exercise those skills in the last six years, preferring to leverage PHPs simplicity whenever possible. So... when I had a need to put together a simple JSP script that queried Oracle, I found myself scouring for a truly simple example to start from. Here's the example I put together:
-
<%@ page import="java.sql.*" %>
-
<%
-
try
-
{
-
//this is how you might get a POST or GET variable from the request to use
-
//String user_id = request.getParameter("some_var");
-
-
Connection conn = DriverManager.getConnection("jdbc:oracle:thin:@HOSTNAME:PORT:SID","USERNAME","PASSWORD");
-
if (rset.next())
-
{
-
out.println(rset.getString(1));
-
}
-
else
-
{
-
out.println("No records found");
-
}
-
rset.close();
-
stmt.close();
-
}
-
out.println("Exception");
-
}
-
%>
Certainly for your own purposes you would need to write a lot more code than this. Yet, if you seek a simple example just to gain your bearings, this should do it.
Tags: code, driver, java, jdbc, jsp, oracle, oracle thin, programming, query, sql, thin, web
Announcing Sun MySQL!
January 16, 2008 | Leave a Comment
Sun has officially acquired MySQL! As a huge fan and supporter of MySQL, I have personal commitment and obvious concerns about this. In my experience most things Sun does are bloated and slow to develop (Solaris, Java, Open Office). Yet, I remain hopeful because they do seem to respect and work positively with open source initiatives.
The most positive things can come out of this are improved marketing, better name recognition, and funds injected into a project. Maybe they can compete with Oracle now? Hey, maybe Sun will stop using Berkeley DB to back most it's existing products. I'll admit that upon first reading this my heart skipped a few beats, but as the pains subsided I think its all going to be OK.
Tags: database, java, lamp, mysql, openoffice, oracle, solaris, Sun, sun microsystems
Google Presentations Coming This Summer
April 17, 2007 | Leave a Comment
Google announced today that presentations are coming to Google Docs and Spreadsheets. This was of course rumored a couple months ago, and certainly expected (or eagerly awaited...) by the tech industry.
From the blog:
we want to welcome the team from Tonic Systems to Google. Tonic, which we've just acquired, is based in San Francisco and Melbourne, Australia. They have some great technology for presentation creation and document conversion, and it will be a great addition as we add presentation sharing and collaboration capabilities to Google Docs & Spreadsheets.
Looking into Tonic a bit more deeply lead to the FAQ on tonicsystems.com:
"Tonic Systems is a San Francisco-based company that provides Java presentation automation products and solutions for document management - Tonic Systems Builder, Tonic Systems Filter, Tonic Systems Transformer, Tonic Systems Viewer, and JarJar Links. Features of their products included text extraction for indexing documents, presentation creation capabilities and document conversion tools."
My only fear is that the technology they are buying as part of the Tonic acquisition is Java based. Docs and Spreadsheets is much lighter as pure javascript and xhtml. I trust Google will strike the appropriate balance and get this new application integrated and working nicely. As soon as screenshots begin to emerge, I'll be sure to post those.
Tags: docs, docs & spreadsheets, docs and spreadsheets, documents, google, google presently, java, javascript, office, powerpoint, presentation, presentations, spreadsheets, tonic, tonic systems, writely
Luminis Statistics from Uportal
February 23, 2007 | 3 Comments
Note: this is a reposting of an article I wrote on LumDev.net April 12, 2005. I am publishing it here because LumDev is currently experiencing technical difficulties. I have not updated this post in any way to reflect new versions or practices. It is still the 2005 article in every way. I would highly recommend reading that article's commentary if LumDev.net is available when you are reading this.
As many of us who use and administer Luminis know, the stats are quite inadequate straight out of the box. There are some improvements in III.2, but they are still not enough. Some posts on here have suggested some other solutions that gain some ground. I have been instead researching Uportal's build in StatsRecorderFactory support. After a lot of trouble initially getting this enabled, Grace Francisco at SCT support was finally able to get me what I was missing to try this out. The following is an account of how to enable these stats outlining what I like and don't like about this solution. In short this is useful, but short of perfect.
1) cd CP_WEBINF/config
2) jar xf ../lib/uPortal.jar properties/portal.properties --> this actually will get picked up by our classpath, and much easier than editing the file, and rejarring it back to uPortal.jar
3) cd properties
4) edit portal.properties
5) change
#org.jasig.portal.services.stats.StatsRecorderFactory.implementation=org.jasig.portal.services.stats.DoNothingStatsRecorderFactory
to
org.jasig.portal.services.stats.StatsRecorderFactory.implementation=org.jasig.portal.services.stats.LoggingStatsRecorderFactory
6) turn the stat recorder settings ON, if you scroll down a few lines you can choose which ones you want.
7) bounce the webserver:
CP_ROOT/bin/rc/70-webserver stop
CP_ROOT/bin/rc/70-webserver start
8) add logging settings to CP_WEBINF/config/cplog4j.properties
# - STATS-RECORDER
log4j.logger.uportal=INFO, stats
log4j.appender.stats=org.apache.log4j.RollingFileAppender
log4j.appender.stats.File=${util.logservice.log4j.directory}/stats.log
log4j.appender.stats.MaxFileSize=10000KB
log4j.appender.stats.MaxBackupIndex=10
log4j.appender.stats.layout=org.apache.log4j.PatternLayout
log4j.appender.stats.layout.ConversionPattern=[%d{ISO8601}] %m%n
These are some of the log entries created in stats.log:
[2005-03-18 17:10:11,828] [INFO] WebServlet [uportal]: STATS-RECORDER: (cpadmin) logged in successfully at Fri Mar 18 17:10:11 MST 2005
[2005-03-18 17:10:30,937] [INFO] WebServlet [uportal]: STATS-RECORDER: Channel [E-mail Channel, 221, u11l1n13] was rendered in layout 1 by (cpadmin) at Fri Mar 18 17:10:30 MST 2005
[2005-03-18 17:10:30,937] [INFO] WebServlet [uportal]: STATS-RECORDER: Channel [Personal Announcements, 210, u11l1n14] was rendered in layout 1 by (cpadmin) at Fri Mar 18 17:10:30 MST 2005
[2005-03-18 17:10:30,937] [INFO] WebServlet [uportal]: STATS-RECORDER: Channel [Campus Announcements, 211, u11l1n15] was rendered in layout 1 by (cpadmin) at Fri Mar 18 17:10:30 MST 2005
[2005-03-18 17:10:30,937] [INFO] WebServlet [uportal]: STATS-RECORDER: Channel [My Headlines, 212, u11l1n17] was rendered in layout 1 by (cpadmin) at Fri Mar
[2005-03-18 17:12:43,015] [INFO] WebServlet [uportal]: STATS-RECORDER: Session destroyed for (cpadmin) at Fri Mar 18 17:12:43 MST 2005
The first major limitation of this is that it is logging all the stats in a file. So in my instance I am running a cron'd process hourly to go in and pick up the stats files, parse them, and load them into Oracle. My table structure is attached so that you can see the sort of info I'm am acquiring. The script I've written is in PHP and if anyone is really interested, I could share that as well. In a perfect world, there would be a Stats Recorder for Oracle, so that it could go straight in without the extra steps. Someone has written RDBMStatsRecorder which hits Postgres. That may be a good base for building an Oracle version. (Google search RDMBStatsRecorder to find out more).
The second limitation is that it is logging all the STATS-RECORDER entries into the cp.log as well as stats.log. This makes for a very dirty cp.log. Someone who knows more about log4j may be able to explain how to resolve this. I unfortunately do not...
The third limitation is that there is not a way to track what tabs are being accessed. This is an important statistic for a bunch of reasons. I reported this desire to support and they entered Enhancement Request #26422 on my behalf. Another option would be to try and glean these from the webserver logs, but of course then you would not have a username and associated role to tie to these stats, so I'm not certain how useful that might be... Better than nothing though.
You can see my PHP code here: http://my.plymouth.edu:81/code/stats.phps
Tags: cplog4j, java, luminis, php, statistics, stats, stats-recorder, sungard, sungardhe, uportal
Debugging/Fixing Sun Calendar Permissions
July 5, 2006 | 2 Comments
As part of the Luminis Platform, we run the Sun Java Enterprise System Calendar Server, previously called SunOne Calendar Server, previously known as iPlanet Calendar Server. As expected, this calendar server has a fairly robust (read complicated) permission system. Invariably, users make setting changes that cause undesirable behavior with their calendar. A common symptom would be that suddenly no other users can find their calendar when searching for them and in turn can't subscribe to the calendar, even if they have the privileges to do that.
So, over the years I've developed a semi-effective process for debugging the calendar permissions from the backend.
- SSH to your calendar server
cdto the calendar server/bindirectory (for Luminis this is$CP_ROOT/products/SUNWics5/cal/bin)- use the cscal utility to query the trouble user. ex
./cscal -v list jpseudo - in the out put you get you'll see a line called 'aces' it will look something like:
CODE:
-
aces=@@o^c^WDEIC^g;@@o^a^RSF^g;someuser^a^rsf^g;someuser^c^^g;anotheruser^a^rsf^g;anotheruser^c^wd^g;someoneelse^a^rsf^g;someoneelse^c^^g;@^a^^g;@^c^^g;someuser^p^r^g;anotheruser^p^r^g;someoneelse^p^r^g
-
- This is the access control list or ACL, it is obviously very hard to read. I use EditPlus to do a regular expression find (;) and replace (;\n) on the permissions to clean it up a bit.
- Now it reads:
@@o^c^WDEIC^g;
@@o^a^RSF^g;
someuser^a^rsf^g;
someuser^c^^g;
anotheruser^a^rsf^g;
anotheruser^c^wd^g;
someoneelse^a^rsf^g;
someoneelse^c^^g;
@^a^^g;
@^c^^g;
someuser^p^r^g;
anotheruser^p^r^g;
someoneelse^p^r^g - Now for a brief aside explaining these individual permissions called access control entries or ACEs...
The ACE consists of four distinct elements separated by a caret (^):- Who - the user or type of user the permission applies to. Valid entries are:
- username
- @@o - all owners
- @@p - primary owner
- @@n - not an owner
- @ - anyone
- What - the thing being accessed. Valid entries here are:
- c - calendar component, events or tasks
- p - calendar properties such as name description owners and so forth
- a - entire calendar including components and properties
- How - what actions are permitted. Valid entries are:
- r - read
- w - write
- d - delete
- s - schedule or invite
- f - free/busy or availability
- e - accept or decline invitations
- i - send invites for events on the calendar
- c - cancel
- Grant - this determines whether or not the ACE is a grant (g) or deny (d)
Now that we have a clue what these ACEs actually represent, how do we go about finding a problem?
- Who - the user or type of user the permission applies to. Valid entries are:
- If the issue is about a single user experiencing trouble with the jpseudo's calendar, then extract only the ACEs that apply to that user or apply globally. If instead it is a generalized issue, eliminate all user specific ACEs and only look at global ones. Either way you should be able to drastically reduce the number of rules you are looking at.
- If this issue is the example originally given where the user's calendar cannot be seen by any users, then we are looking for a permission like @^p^r^g; or something similar. If the problem is not readily apparent, it is often useful to compare another user who you know works against this problem user.
- Now it is time to modify the permissions. More specific entries should be ordered first, this allows them to override entries that come later.
- Once you have the entries ordered properly, the command you need to execute will look something like this:
CODE:
-
./cscal -a "@@o^c^WDEIC^g;@@o^a^RSF^g;someuser^a^rsf^g;someuser^c^^g;anotheruser^a^rsf^g;anotheruser^c^wd^g;someoneelse^a^rsf^g;someoneelse^c^^g;@^a^^g;@^c^^g;someuser^p^r^g;anotheruser^p^r^g;someoneelse^p^r^g;@^p^r^g" modify jpseudo
-
- Hopefully the change you made succeeds and life is good, if not, rinse and repeat!
Tags: ACE, aces, ACL, acls, application administration, calendar, iPlanet Calendar Server, java, luminis, luminis platform, Sun, Sun Java Enterprise System Calendar Server, sungard, sungard higher education, SunOne Calendar Server, system administration
Scriptaculous
January 6, 2006 | 1 Comment
Matt recently came across and got very excited about Script.aculo.us for doing DHTML effects and AJAX.
From Matt's post: Script.aculo.us Is My New Best Friend:
Script.aculo.us is a Javascript Effects and Control framework developed by Thomas Fuchs, a software architect living in Vienna, Austria who, like me, was disappointed by current web application frameworks that made no sense to him. His framework is 3 things: Easy to Use, Simple, and Easy to Use. His libraries - built off of the AJAX framework, Prototype - blow SAJAX out of the water!
One of the things that makes script.aculo.us especially great is the detailed and well written documentation/apis. Arguably, this is why I first loved Java and eventually became addicted to PHP. The Java API was great, but PHP.net is unmatched. Like PHP.net, the script.aculo.us wiki allows users to contribute back knowledge easily.
Tags: AJAX, api, apis, dhtml, java, php, programming, prototype, SAJAX, scriptaculous, web, web application, web development, wiki
Cheat Sheets
August 5, 2005 | 38 Comments
I love cheat sheets or euphemistiically, quick references. I find myself becoming quite familiar with something, then not using it for 6 months. After time away from something like that a cheat sheet is the best way of getting back up to speed quickly. Also, good cheat sheets sometimes show me features or functionality I wasn't previously familiar with. Consider this Cliff Notes for technology.
JavaScript, MySQL, mod_rewrite, CSS, and PHP(Thanks Casey)
VI (PDF)
Perl Regular expressions (PDF)
Java (PDF) (Not so quick...)
Update 2/20/06:
Prototype JS Library - from BorkWeb.
Still looking for a good one on Oracle and always looking for better ones. Also check this site for some more, though I'm not real excited about most of them.
Tags: cheat sheet, cheat sheets, cheatsheet, cheatsheets, cliff notes, css, development, java, javascript, mod_rewrite, mysql, oracle, perl, php, quick guides, quick reference, regular expressions, vi, web, web development
