Sunday, May 18, 2014

Seam

At the heart of Seam is the contextual component model.
(1) Seam is a factory that constructs objects according to component definitions.
(2) After creation, each object is stored in the container under one of several contexts (i.e. variable scopes) with varying lifetimes, making the objects contextual and capable of holding state (i.e.stateful).
(3) Seam promotes the interaction of these stateful objects across contexts, assembling them together

Monday, March 24, 2014

Python

Python is a dynamic, strongly typed, object oriented, multipurpose programming language, designed to be quick (to learn, to use, and to understand), and to enforce a clean and uniform syntax.
  1. Python is dynamically typed: it means that you don't declare a type (e.g. 'integer') for a variable name, and then assign something of that type (and only that type). Instead, you have variable names, and you bind them to entities whose type stays with the entity itself. a = 5 makes the variable name a to refer to the integer 5. Later, a = "hello" makes the variable name a to refer to a string containing "hello". Static typed languages would have you declare int a and then a = 5, but assigning a = "hello" would have been a compile time error. On one hand, this makes everything more unpredictable (you don't know what a refers to). On the other hand, it makes very easy to achieve some results a static typed languages makes very difficult.
  2. Python is strongly typed. It means that if a = "5" (the string whose value is '5') will remain a string, and never coerced to a number if the context requires so. Every type conversion in python must be done explicitly. This is different from, for example, Perl or Javascript, where you have weak typing, and can write things like "hello" + 5 to get "hello5".
  3. Python is object oriented, with class-based inheritance. Everything is an object (including classes, functions, modules, etc), in the sense that they can be passed around as arguments, have methods and attributes, and so on.
  4. Python is multipurpose: it is not specialised to a specific target of users (like R for statistics, or PHP for web programming). It is extended through modules and libraries, that hook very easily into the C programming language.
  5. Python enforces correct indentation of the code by making the indentation part of the syntax. There are no control braces in Python. Blocks of code are identified by the level of indentation. Although a big turn off for many programmers not used to this, it is precious as it gives a very uniform style and results in code that is visually pleasant to read.
  6. The code is compiled into byte code and then executed in a virtual machine. This means that precompiled code is portable between platforms.

Sunday, February 16, 2014

Differences between Interface and Abstract Class

  1. Main difference is methods of a Java interface are implicitly abstract and cannot have implementations. A Java abstract class can have instance methods that implements a default behavior.
  2. Variables declared in a Java interface is by default final. An  abstract class may contain non-final variables.
  3. Members of a Java interface are public by default. A Java abstract class can have the usual flavors of class members like private, protected, etc..
  4. Java interface should be implemented using keyword “implements”; A Java abstract class should be extended using keyword “extends”.
  5. An interface can extend another Java interface only, an abstract class can extend another Java class and implement multiple Java interfaces.
  6. A Java class can implement multiple interfaces but it can extend only one abstract class.
  7. Interface is absolutely abstract and cannot be instantiated; A Java abstract class also cannot be instantiated, but can be invoked if a main() exists.
  8. In comparison with java abstract classes, java interfaces are slow as it requires extra indirection.

Monday, February 3, 2014

jasperviewer closes main application

at the time of closing jasperviewer report that is opened up, main application window is closed at the same time.To get rid form this problem:

in the constructor of JasperViewer there is boolean indicating whehter it should perform an exit on close.

jasperReport = JasperCompileManager.compileReport( "reportloh.jrxml");
jasperPrint = JasperFillManager.fillReport( jasperReport, parameters, conn);
JasperViewer jv = new JasperViewer( jasperPrint, false );
jv.viewReport( jasperPrint, false );
 

Wednesday, January 15, 2014

To add a new user to a MySQL database from the Linux command line

This method should work from any operating system that uses the MySQL client application from a terminal.
First we need to log into MySQL on a server so lets do that right now.

 
mysql -u root -p
Then enter your password and hit enter. Now we want to create a database which our new user will have privileges on. If you already have a database you can skip this step.


mysql > create database new_database;
 
Now with our new database in place called new_database we can move on and set up a user for this schema.


mysql > grant usage on *.* to new_database_user@localhost identified by user_password';
 
Now we want the new user to be able to do almost everything in the new database so we run:

mysql > grant all privileges on new_database.* to new_database_user@localhost;
Now to make sure all the settings we entered stick we run:


mysql > flush privileges;
 
Now you should be able to easily log in to the database called new_database on the localhost. If you wanted the user to be able to access the database from any location than you would run the following line instead of the one above:


mysql > grant usage on *.* to new_database_user@'%' identified by 'user_password';
 
Hope this helps people remember how to add users really is in MySQL on the command line.