Tuesday, September 28, 2010

Dummy Credit Cards for Testing

Hi,

The following are dummy credit card numbers you can use for testing ...



Card Type Card Number
American Express 378282246310005
American Express 371449635398431
American Express Corporate 378734493671000
Australian BankCard 5610591081018250
Diners Club 30569309025904
Diners Club 38520000023237
Discover 6011111111111117
Discover 6011000990139424
JCB 3530111333300000
JCB 3566002020360505
MasterCard 5555555555554444
MasterCard 5105105105105100
Visa 4111111111111111
Visa 4012888888881881
Visa 4222222222222
Dankort (PBS) 76009244561
Dankort (PBS) 5019717010103742
Switch/Solo (Paymentech) 6331101999990016


Don't you hate when someone turns you ON and leaves ??? SAVE ELECTRICITY.
-S

Sunday, August 29, 2010

Java Mail - Send email the Java way

Send Email using Java Mail API



Using ELOH to say HELO
-S

Thursday, August 26, 2010

Linux Permissions

It doesn't belong here ... but was worth sharing.
  • chmod /*change the permissions of a file*/
  • chown /*change the owner of the file*/
  • chgrp /*change the group that the file belongs to*/
example:
chmod 777 somefile.file /*this gives exe write and read to all */ not recommended for any file.

For chmod here is a list of the numbers and what they mean
  • the 100's are for the owner of the file
400 reed
200 write
100 execute
  • 10's are for the group of the file
40 read
20 write
10 execute
  • 1's are for everyone else
4 read
2 write
1 execute

you add the number together to get different permissions


Time is the most precious thing one can give . -S

Tuesday, August 24, 2010

Common Connection Strings

A List of JDBC Drivers
If you need to access a database with Java, you need a driver. This is a list of the drivers available, what database they can access, who makes it, and how to connect them.

IBM DB2
jdbc:db2://:/
com.ibm.db2.jdbc.app.DB2Driver

JDBC-ODBC Bridge
jdbc:odbc:
sun.jdbc.odbc.JdbcOdbcDriver

Microsoft SQL Server
jdbc:weblogic:mssqlserver4:@:
weblogic.jdbc.mssqlserver4.Driver

Oracle Thin
jdbc:oracle:thin:@::
oracle.jdbc.driver.OracleDriver

PointBase Embedded Server
jdbc:pointbase://embedded[:]/
com.pointbase.jdbc.jdbcUniversalDriver

Cloudscape
jdbc:cloudscape:
com.cloudscape.core.JDBCDriver

Cloudscape RMI
jdbc:rmi://:/jdbc:cloudscape:
RmiJdbc.RJDriver

Firebird (JCA/JDBC Driver)
jdbc:firebirdsql:[//[:]/]
org.firebirdsql.jdbc.FBDriver

IDS Server
jdbc:ids://:/conn?dsn=''
ids.sql.IDSDriver

Informix Dynamic Server
jdbc:informix-sqli://:/:INFORMIXSERVER=
com.informix.jdbc.IfxDriver

InstantDB (v3.13 and earlier)
jdbc:idb:
jdbc.idbDriver

InstantDB (v3.14 and later)
jdbc:idb:
org.enhydra.instantdb.jdbc.idbDriver

Interbase (InterClient Driver)
jdbc:interbase:///
interbase.interclient.Driver

Hypersonic SQL (v1.2 and earlier)
jdbc:HypersonicSQL:
hSql.hDriver

Hypersonic SQL (v1.3 and later)
jdbc:HypersonicSQL:
org.hsql.jdbcDriver

Microsoft SQL Server (JTurbo Driver)
jdbc:JTurbo://:/
com.ashna.jturbo.driver.Driver

Microsoft SQL Server (Sprinta Driver)
jdbc:inetdae::?database=
com.inet.tds.TdsDriver

Microsoft SQL Server 2000 (Microsoft Driver)
jdbc:microsoft:sqlserver://:[;DatabaseName=]
com.microsoft.sqlserver.jdbc.SQLServerDriver

MySQL (MM.MySQL Driver)
jdbc:mysql://:/
org.gjt.mm.mysql.Driver

Oracle OCI 8i
jdbc:oracle:oci8:@
oracle.jdbc.driver.OracleDriver

Oracle OCI 9i
jdbc:oracle:oci:@
oracle.jdbc.driver.OracleDriver

PostgreSQL (v6.5 and earlier)
jdbc:postgresql://:/
postgresql.Driver

PostgreSQL (v7.0 and later)
jdbc:postgresql://:/
org.postgresql.Driver

Sybase (jConnect 4.2 and earlier)
jdbc:sybase:Tds::
com.sybase.jdbc.SybDriver

Sybase (jConnect 5.2)
jdbc:sybase:Tds::
com.sybase.jdbc2.jdbc.SybDriver

To test your driver once it's installed, try the following code:


{
Class.forName("Driver name");
Connection con = DriverManager.getConnenction("jdbcurl","username","password");
//other manipulation using jdbc commands
}
catch(Exception e)
{
}


Thursday, August 19, 2010

Removing the Extra Fat - JBoss

You can remove the following components:

  • AOP Application
  • Cache invalidation service (keep for a clustered installation)
  • Console/e-mail monitor alerts
  • CORBA/IIOP
  • HTTP Invoker
  • Hibernate session Management services
  • HSQL DB
  • Integrated HAR deployer
  • J2EE client deployer service
  • JBoss scheduler manager
  • JMX Console
  • Mail service
  • Management console
  • Sample Schedule service
  • Scheduler service
  • Test queues and topics
  • UUID key Generation
  • Web services support

You can remove all or selected ones depending on what services of JBoss your application will be using. Generally applications have their own implementation of Schedulers, Mail services Queues etc. but if you are dependent on JBoss's implementation then choose wisely.

How and What to remove:

For removing the ones listed above you need to take care of their dependencies else JBoss will be sad and fill your log.

Slimming helps ... LEANER your code FATTER your salary ... :) .
-S

Wednesday, August 18, 2010

SSL and JBOSS : Baby Steps

I am not sure how many of you have visited http://24x7-java.blogspot.com/ and felt good.

You'll find lots of pages describing the process of enabling ssl on JBoss, but many of them explain in a way which it too technical. The intention here is to let everyone do it easily (on windows OS).

So describing it in baby steps

Q. What you need?

A. JDK and JBoss


Step 1. Open command prompt and goto bin directory under JDK (not jre) and execute

keytool -genkey -alias tomcat -keyalg RSA

(if you have JAVA_HOME/bin in your system path then you can just execute the above command on the prompt ).

You'll be prompted for the following and fill as per your need.


Enter keystore password:
Re-enter new password:
What is your first and last name?
[Unknown]: Sunil

What is the name of your organizational unit?
[Unknown]: development

What is the name of your organization?
[Unknown]: test

What is the name of your City or Locality?
[Unknown]: Shimla

What is the name of your State or Province?
[Unknown]: HP

What is the two-letter country code for this unit?
[Unknown]: IN

Is CN=Sunil, OU=development, O=test, L=Shimla, ST=HP, C=IN correct?
[no]: Yes

Enter key password for
(RETURN if same as keystore password):

Keep the key password same as your keystore for ease.


Step 2. Copy the default keystore created in your C:\Documents and Settings\<currently-loggedin-user>.keystore
to
<drivepath>:\jboss\server\default\conf and rename it to my.keystore


Step 3. Edit file
<drivepath>:\jboss\server\default\deploy\jboss-web.deployer\server.xml
or
<drivepath>:\jboss\server\default\deploy\jbossweb-tomcat55.sar\server.xml
depending on the version of jBoss and make the following changes.


<Connector port="443" protocol="HTTP/1.1" SSLEnabled="true"
maxThreads="150" scheme="https" secure="true"
clientAuth="false"
strategy="ms"
address="${jboss.bind.address}"
keystoreFile="${jboss.server.home.dir}/conf/my.keystore"
keystorePass="keypassword"
truststoreFile="${jboss.server.home.dir}/conf/my.keystore"
truststorePass="keypassword"
sslProtocol="TLS"/>


Step 4. Start you jboss run -c default and thats all. Your application will now be avaliable on both http:// and https:// . If you want to disable http:// Comment the tag below in server.xml


<Connector port="80" address="${jboss.bind.address}"
maxThreads="250" maxHttpHeaderSize="8192"
emptySessionPath="true" protocol="HTTP/1.1"
enableLookups="false" redirectPort="443" acceptCount="100"
connectionTimeout="20000" disableUploadTimeout="true" />


The Connector port is by default 8080.




Computer never makes mistake ... its always the human part
-S

Tuesday, March 23, 2010

Tuesday, February 23, 2010

Will Oracle kill Java Community

I spent my few hours going through various forums and reading about the after effects of the one of the biggest mergers in software industry, Oracle's acquisition of Sun. There were concerns which made me think too.


  1. Will MySQL die ?
    Being Database giant will Oracle support MySQL or silently kill it. The database market is currently ruled by three major companies - IBM, Microsoft and Oracle - controlling 85 per cent of the market in revenue terms and Sun's MySQL (free and open source) will extend further into Oracle's market as its functionality improves. So why will Oracle support it?

  2. Future of GlassFish ?
    Will GlassFish become extinct? Oracle already sells WebLogic (after it acquired BEA Systems) and Oracle Application Server. Oracle may say no to support GlassFish project as it already has to support two identical application servers.

  3. What will happen to NetBeans?
    Oracle is a strong supporter of Eclipse so NetBeans might die with time as well.

Oracle has to get everyone together as soon as possible to spell out their future plans for Java Community. If Oracle doesn’t, they’ll have Java developers running, not walking, away from the Sun/Oracle Java as fast as they can.

The fate of language depends on how many people respond back to its "Hello World"
-S