MySQL is Not pronounced MY SQL

April 29, 2008

Ok - this is not exactly hot news. But I went to an EXCELLENT seminar on Friday last week with Sun and MYSQL. Which according to the founder is pronounced “MESQL” as the “MY” is the name of his daughter. Well, translated it’s “MY” not “ME”, I tried saying MESQL but it makes me sound like a Texan. (sorry if you Texan). So I’m sticking to MYSQL.

They spent a lot of time trying to convince us that the open source software model (that Sun use) is the way to go for software. You know, install it, make it work - if you want support pay for it. I liked this for a number of reasons and didn’t like it for other reasons.

Why I Like Open Source

- Customer and you can get the software, run it, test it, see if it’s what they need and then upgrade to a commercial license and support whent they are happy
- Customer can get the “best of breed” and mix and match
- Source code is available if supplier goes bust (ok, I know Sun & MYSQL are not going bust but it’s a thought)
- For the developer its less pressure than working on a project where you are up against deadlines for a client. However this also means the development may be less focussed on solving a particular problem, one of the comments was that Open Source payroll “Isn’t mature enough yet”, well that’s fine but its not cheese. It won’t just mature, someone, somewhere has to fund the development (see bad points). In this model:- 

a. Customer pays a license fee to use the commercial version (they call it Enterprise in the Open Source World)
b. Customer pays a support fee to use the commercial version - or hires in house people to support it
c. Customer pays when they are happy or at least ready to get professional help.
d. I like the 15 minute rule, if I can’t install it and have it running in 15 minutes (even though it mike take 2 hours) to download then its probably not ready.
- Open source is better for the smaller company because they can get other developers to contribute and people to file bug reports for example when something is not working.
- Open source means that developers get recognition in the developer community for work they have done especially if it is pioneering. Developers need encouragement and sometimes in a small team they don’t get it. Especially being the only developer in a company, it’s unlikely that those outside of the software engineering world have any understanding about the elegance and effort put into a peice of software, I’ve seen bad software that looks great but is terrible and great software that looks terrible but works like a dream. (often us developers need to hire a designer!).

Bad Points about open source

- Developers need to feed their kids - so unless someone funds the development then Developer doesn’t feed kids until someone pays a support contract, most developers are not rich enough to live on thin air.
- Unless someone funds it a project may take longer to develop than with the conventional hire a developer model and not be “quite” what the customer was looking for in the first instance. Thus the best open source software is the GENERAL stuff, that is not focused on doing a specific job, like payroll or transport. Because from the base platform you can build up to do something specific.

So, it’s scarey and nice at the same time. Yes, I love open source but Yes, I need to be paid to develop so I can feed my family (and they are hungry, especially the cat).

So what about MySQL itself, well it’s great, thats all there is too it. I love the way I can change database engines PER TABLE which means that for instance if I have an archive I can just use an archive database, I love the clustering, I even like the logo. Good job.

Sun buying it? Well I wrote an article about this on this blog anyway so you can trawl through if you like and read it.

Great Seminar, well worth going, only thing was, not enough freebies. Good grief Sun I travelled an hour accross London. I expect at least a CD and T-Shirt, not just a pen! A PEN!, ok they were giving away an IPhone, which was nice but I never found out who got that. I guess one of the big banks who were there.

If you fancy doing the presentations to yourself you can download them here.


Build Plugins for Firefox EASY!

April 24, 2008

http://wiki.netbeans.org/MozillaAddonDevelopment

Funnily enough there are not a lot of plugins that make me excited but this one does! You can build plugins for Netscape and other products USING OUR BELOVED NETBEANS!

Short post but high quality!


A Page tracking system…

April 23, 2008

Using server faces its possible to store up the pages a user has visited in an order. This was useful for me because I needed one page to be called from a lot of other places and “javascript:history.back()” wasn’t working because when the user clicks buttons on the page, the back page is the last one!.

So first setting up the session bean.

In the session bean I added a public string.

    public String[] sURL={"","","","",""};

And some functions to support it:-

public void StoreURL(String sURLtoSearch) {
// this routine keeps a history of 5 urls
// that the user has visited
// so that we can correctly link back to the last one
if (sURL[0].equals(sURLtoSearch)) {
return;
}
// its different lets do the shuffle
for (int i=4;i>0;--i) {
sURL[i]=sURL[i-1];
}
sURL[0]=sURLtoSearch;
}
public String getURLs() {
String result="";
for (int i=0;i<5;++i) {
result=result.concat(sURL[i]);
}
return result;
}
public String getLastPage() {
// returns the last page visited
return sURL[0];
}

Then on the the pagefragment I have on all the pages (header) I added the code:-

HttpServletRequest request= (HttpServletRequest)FacesContext.getCurrentInstance().getExternalContext().getRequest();
try {
 String sURL=request.getRequestURL().toString();
        sURL=sURL.substring(sURL.lastIndexOf("/")+1);

        getSessionBean1().StoreURL(sURL);

} catch (Exception e) {
}

I’ve left it pretty for you but its now down to one line.

Then lets say I have a Hyperlink I want to link back to the last page…

hypWHEREFROM.setUrl(getSessionBean1().getLastPage() );

And off we go.


Netbeans 6.1 & Jasper Reports - a Marriage made in heaven or somewhere else nice.

April 17, 2008

Ok

I’m nearly ready to roll out a big course booking application so I needed to start implementing the reports and just like everyone else I chose Jasper Reports netbeans plugin.

BRILLIANT, we are delivering the reports in PDF format so its easy for the customer to email or print them as required.

How is it done?

1. Install the Netbans Jasper Reports plugin file (NBM download from the Jasper Reports website)

2. Add the Jasper Reports Snapshot viewer library to your project

3. Right click your web project, then Add a Jasper Report - I decided it would be nice to use the wizard and go from there -

a. hint - you need to add the extension .jrxml to the filename so netbeans knows what it is.
b. FOLDER - put it in the WEB folder

4. Edit your report and save

Now the dirty code….

I modded this code from another site to make it work with Netbeans 6 and with having the file located in the WEB directory.

/**
 * <p>Generate the specified report, in the specified output
 * format, based on the specified data.</p>
 *
 * @param name Report name to be rendered
 * @param type Content type of the requested report ("application/pdf"
 *  or "text/html")
 * @param data <code>ResultSet</code> containing
 *  the data to report
 *
 * @exception IllegalArgumentException if the specified
 *  content type is not recognized
 * @exception IllegalArgumentException if no compiled report definition
 * for the specified name can be found
*/
public void jasperReport(String name, String type,
ResultSet data) {
jasperReport(name, type, data, new HashMap());
}

/**
 * <p>Generate the specified report, in the specified output
 * format, based on the specified data.</p>
 *
 * @param name Report name to be rendered
 * @param type Content type of the requested report ("application/pdf"
 *  or "text/html")
 * @param data <code>ResultSet</code> containing the data to report
 * @param params <code>Map</code> of additional
 *   report parameters
 *
 * @exception IllegalArgumentException if the specified
 *  content type is not recognized
 * @exception IllegalArgumentException if no compiled report definition
 * for the specified name can be found
*/
public void jasperReport(String name, String type,
ResultSet data, Map params) {

// Validate that we recognize the report type
// before potentially wasting time filling the
// report with data
boolean found = false;
for (int i = 0; i < VALID_TYPES.length; i++) {
if (VALID_TYPES[i].equals(type)) {
found = true;
break;
}
}
if (!found) {
throw new IllegalArgumentException("Invalid report type '"
+ type
+ "' requested");
}

// Look up the compiled report design resource
ExternalContext econtext = getExternalContext();
InputStream stream = econtext.getResourceAsStream(PREFIX + name
+ SUFFIX);
if (stream == null) {
throw new IllegalArgumentException("Unknown report name '"
+ name
+ "' requested");
}

try {
data.beforeFirst();
} catch (Exception e) {
throw new FacesException(e);
}

// Fill the requested report with the specified data
JRResultSetDataSource ds = new JRResultSetDataSource(data);
JasperPrint jasperPrint = null;
try {
jasperPrint = JasperFillManager.fillReport(
stream, params, ds);
} catch (RuntimeException e) {
throw e;
} catch (Exception e) {
throw new FacesException(e);
} finally {
try {
stream.close();
} catch (IOException e) {

}
}

// Configure the exporter to be used, along with the custom
// parameters specific to the exporter type
JRExporter exporter = null;
HttpServletResponse response = (HttpServletResponse)
econtext.getResponse();
FacesContext fcontext = FacesContext.getCurrentInstance();
try {
response.setContentType(type);
if ("application/pdf".equals(type)) {
exporter = new JRPdfExporter();
exporter.setParameter(JRExporterParameter.JASPER_PRINT,
jasperPrint);
exporter.setParameter(JRExporterParameter.OUTPUT_STREAM,
response.getOutputStream());
} else if ("text/html".equals(type)) {
exporter = new JRHtmlExporter();
exporter.setParameter(JRExporterParameter.JASPER_PRINT,
jasperPrint);
exporter.setParameter(JRExporterParameter.OUTPUT_WRITER,
response.getWriter());
// Make images available for the HTML output
HttpServletRequest request =
(HttpServletRequest)
fcontext.getExternalContext().getRequest();
request.getSession().setAttribute(
ImageServlet.DEFAULT_JASPER_PRINT_SESSION_ATTRIBUTE,
jasperPrint);
exporter.setParameter(
JRHtmlExporterParameter.IMAGES_MAP, new HashMap());
// The following statement requires mapping /image
// to the imageServlet in the web.xml.
//
// This servlet serves up images including the px
// images for spacing.
//
// Serve up the images directly so we
// don't incur the extra overhead associated with
// with a JSF request for a non-JSF entity.
exporter.setParameter(JRHtmlExporterParameter.IMAGES_URI,
request.getContextPath() + "/image?image=");
}
} catch (RuntimeException e) {
throw e;
} catch (Exception e) {
throw new FacesException(e);
}

// Enough with the preliminaries ...
// export the report already
try {
exporter.exportReport();
} catch (RuntimeException e) {
throw e;
} catch (Exception e) {
throw new FacesException(e);
}

// Tell JavaServer Faces that no output is required
fcontext.responseComplete();

}

private void jasperReport(String name, String type, ResultSet data, HashMap hashMap) {
throw new UnsupportedOperationException("Not yet implemented");
}

Now to code a button to print to a PDF. Create a table and drop some data in it. Then also go look at the XML source code of your report, you’ll see the SQL query there you’ll need to copy that and paste it in.

In this case my grid has created a CachedDataRowProvider1() so I use that to supply the data for the report. Note that I also set up a Static Text box and named it txtRESULT just incase I get any problems (don’t forget to add the binding attribute).

public String button3_action() {
Map fillParams = new HashMap();
// The above statement generates warnings with Java SE 1.5
// To eliminate the warnings, replace with the
// following statement:
// Map<String, URL> fillParams =
//   new HashMap<String, URL.>>();
try {
String sSaveSQL=getSessionBean1().getCoursesRowSet1().getCommand();
// Set up the data provider to match your SQL code from the report.
getSessionBean1().getCoursesRowSet1().setCommand(
"SELECT  courses.`coursetitle` AS courses_coursetitle," +
" courses.`coursedescription` AS courses_coursedescription, " +
" courses.`price` AS courses_price, "+
" courses.`kitprovided` AS courses_kitprovided, "+
" courses.`days` AS courses_days "+
" FROM `courses` courses "+
" ORDER BY courses.`coursetitle`");
getSessionBean1().getCoursesRowSet1().execute();
getApplicationBean1().jasperReport
("Courses", "application/pdf",
getSessionBean1().getCoursesRowSet1(), fillParams);
getSessionBean1().getCoursesRowSet1().setCommand(sSaveSQL);
} catch (Exception e) {
txtRESULT.setText("Exception generating report: " + e);
}
return null;

}

and that should do it. My thanks for getting me started (and most of the code goes to this) http://www.netbeans.org/kb/55/vwp-reports.html

Note that you do not have to do most of the setup in that document as Netbeans now does it for you. Just install the plugin, add the libraries, use the code and off you go.


Netbeans 6.1 RC is out HOORAY!

April 14, 2008

So with great excitement I downloaded Netbeans 6.1 RC which is great, only problem I had was my existing project loaded up and complained about missing references and then wouldnt run even when I had corrected the missing references.

The problem seems to be something to do with the persistance.xml file. I found that by “fiddling” and saving, rebooting etc I fixed it.

What about it then? well it’s more stable that’s for sure and works really well, I still can’t get my checkboxes to bind properly to BIT fields in server faces. Not without writing code to do it, but I’m sure it worked in 6.0.1.

It’s much faster and I love the add binding attribute thing. I’m releasing an app to a  client this week written in server faces running on a web browser that will be mostly developed in 6.1.


Second Life Solaris Viewer - WINDLIGHT VERSION

April 9, 2008

You want it… you’ve got it thanks to Clark Dastardly for these links.

Solaris X86

https://solaris-sl-viewer.s3.amazonaws.com/SecondLife_i686_1_19_1_4-2008Apr07-s10.pkg.bz2

Solaris Nevada (Open Solaris)

https://solaris-sl-viewer.s3.amazonaws.com/SecondLife_i686_1_19_1_4-2008Apr07-snv.pkg.bz2

 

Download, extract and use

 

pkgadd -d FILENAME to extract. Remember to do SU so you are logged in as ROOT.

 

Then Navigate to opt\secondlife\bin

 

and run

 

./secondlife

 

You may need to adjust your graphics settings, also turn OFF avatar imposters if you get a black box.

 


CVS with netbeans and Tomorrow…

April 8, 2008

I decided it was time to start using CVS with Netbeans to manage our projects, since I had an old LINUX box set up I went ahead and installed a CVS server (the box is running UBUNTU 7.10) the setup on the server was very simple and Netbeans just connected to it and came ALIVE with code management.

Just brilliant, even if you set it up your local machine its worth it. The menu additions in Netbeans mean its VERY easy to check in and out and compare code. Good use of a spare PC.

Good Job! (ofcourse you could use Mecurial or the other one that escapes me).

Tommorrow I am giving a short seminar on Netbeans and Glassfish at work in the evening so that should be fun.


Using Netbeans/Glassfish with Sharepoint #1

April 5, 2008

Good news folks.

Ok this is still theoretical but I can’t see how it will not work

Here’s ONE way to use sharepoint with Netbeans and Glassfish.

a. Create a WEB service in Netbeans to deliver the data you want into Sharepoint
b. Follow these instructions http://weblogs.asp.net/bsimser/archive/2004/12/26/332467.aspx to bring your service into Sharepoint.

You can also obviously use Java Server Faces and Glassfish or even a stand alone application to build an application to control sharepoint using Webservices.

To be honest the only way in a million years I’d bother with sharepoint is if the customer already had it on their site and needed to integrate or have some custom programming.

I am still looking into seeing if we could provide a simple .net wrapper into a java class that could allow a more direct input into sharepoint.

My main problem folks is I’ve got two projects on and one has to be delivered soon (I’m nearly there) so research time is a bit limited at the moment.

Check the article before this as well.

Here’s a schematic just to help you work it out… as you can see by using EJB’s we could build the applications intelligence at the server end. Obviously ANYTHING that could use a web service could access the applications data, not just sharepoint.


Sharepoint & Netbeans Pipedream?

April 3, 2008

OK

Now we’ve decided, not me the ROYAL WE that we want to use Microsoft Sharepoint for certain applications. So rather than spend a fortune on .net I’ve been looking at if it’s possible to write Web Parts with Netbeans. This sounds a little crazy I know but lets just look at it.

A web part is composed of a “Web part Description file” .dwp and a .NET assembly or .dll file. Now this sounds like at the first instance we are stuck since java ofcourse produces “JAR” files not “.DLL” files. The second problem is that even if we were to “wrap” the Java in a DLL it would not be as good as say running a Glassfish server with java server faces native.

Then I discover that we can use WSDL to talk to share point! http://www.infoq.com/articles/swanson-moss-web-services suggests that we can use soap to talk to sharepoint (cleanly!) which is fantastic. So I’m going to explore that and then post here on how we can actually do the job.

In fact the URL’s are listed here  http://www.developer.com/tech/article.php/3104621 and as the Netbeans IDE has a way to consume web services it’s simply a matter of giving it a go.


April Fool?

April 1, 2008

http://blogs.sun.com/roumen/entry/netbeans_7_0_plans_uncovered

So Netbeans 7.0 Will be rewritten in Javascript!

Yeah Right. Anyone in my development team who believes this will be immediately fired.