Analytics


Google

Saturday, April 16, 2016

Script to get your Windows Key

I found the following article on how to obtain the Windows Key without installing any third party software. This is useful but may not be necessary to reinstall your windows should you want perform a fresh Windows install; especially for those who did a Windows 10 upgrade.

The script is as follow:

Set WshShell = CreateObject("WScript.Shell")
MsgBox ConvertToKey(WshShell.RegRead("HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\DigitalProductId"))

Function ConvertToKey(Key)
Const KeyOffset = 52
i = 28
Chars = "BCDFGHJKMPQRTVWXY2346789"
Do
Cur = 0
x = 14
Do
Cur = Cur * 256
Cur = Key(x + KeyOffset) + Cur
Key(x + KeyOffset) = (Cur \ 24) And 255
Cur = Cur Mod 24
x = x -1
Loop While x >= 0
i = i -1
KeyOutput = Mid(Chars, Cur + 1, 1) & KeyOutput
If (((29 - i) Mod 6) = 0) And (i <> -1) Then
i = i -1
KeyOutput = "-" & KeyOutput
End If
Loop While i >= 0
ConvertToKey = KeyOutput
End Function

Monday, August 24, 2015

Java Web Tier Framework Comparison

I found this old reference in my collection, not sure how much of this is still valid but thought of posting it here so it will not get loss.



FrameworkDescriptionProsConsReference InfoLicensing
GWTGoogle Web Toolkit (GWT) is an open source Java software development framework that makes writing AJAX applications easy for developers who don't speak browser quirks as a second language.
You write your front end in the Java programming language, and the GWT compiler converts your Java classes to browser-compliant JavaScript and HTML
No JavaScript syntax errors
- Use a reliable, strongly-typed language (Java) for development and debugging
- No JavaScript programming at all!
Can use complex Java on the client
- Turned into JavaScript, but you still use String, array, Math class, ArrayList, HashMap, custom classes, etc.
- Full IDE-based Java support for development/debugging (GWT builds Eclipse or MyEclipse projects automatically)
Can send complex Java types to and from the server
- Data gets serialized across network
Standalone test environment
- Can test within MyEclipse without installing a server
Support by major company
- From the company that helped to popularize Ajax in the first place. But project is free, open-source, and in no way tied to Google products or services.
- Company won't go away like perhaps with AjaxTags
Big learning curve
- Java developers can deploy with AjaxTags (or other JSP tag libraries that wrap Ajax functionality) in just a few minutes, whereas it takes much longer to get anything running with GWT.
Cumbersome deployment
- Clumsy and poorly documented process to deploy on a regular Java-based Web server.
Nonstandard approach to integrate JavaScript
- You never put direct JavaScript in your HTML. Instead, you use JSNI to wrap JavaScript in Java. Very powerful in the long run, but hard to get used to at first.
Only for Java developers
- Most Ajax environments do JavaScript on the client and have a choice for the server. GWT is based entirely around Java.
Unusual approach
- Fundamentally different strategy than all other Ajax environments makes evaluation and management buyoff harder
Lack of Java 5 Support in current version GWT 1.4
It’s hard to attach GWT on top of existing code
http://code.google.com/webtoolkit/Freeware
Struts 2Apache Struts 2 is an elegant, extensible framework for creating enterprise-ready Java web applications. The framework is designed to streamline the full development cycle, from building, to deploying, to maintaining applications over time.Simple architecture - easy to extend
Tag Library is easy to customize with
FreeMarker or Velocity
Controller-based or page-based navigation
Documentation is poorly organized
No feedback for missing properties or invalid
OGNL expressions
Googling results in Struts 1.x documentation
http://struts.apache.org/2.x/Freeware
JSFJavaServer Faces technology simplifies building user interfaces for JavaServer applications. Developers of various skill levels can quickly build web applications by: assembling reusable UI components in a page; connecting these components to an application data source; and wiring client-generated events to server-side event handlers.Java EE Standard - lots of demand and jobs
Fast and easy to develop with initially
Lots of component libraries
Tag soup for JSPs
Doesn't play well with REST or Security
No single source for implementation
http://java.sun.com/javaee/javaserverfaces/Freeware
Spring MVCThis framework is highly configurable via strategy interfaces, and accommodates multiple view technologies like JSP, Velocity, Tiles, iText, and POI. Note that a Spring middle tier can easily be combined with a web tier based on any other web MVC framework, like Struts, WebWork, or Tapestry.Lifecyle for overriding binding, validation, etc.
Integrates with many view options seamlessly:
JSP/JSTL, Tiles, Velocity, FreeMarker, Excel, PDF
Inversion of Control makes it easy to test
Configuration intensive - lots of XML
Almost too flexible - no common parent
Controller
No built-in Ajax support
http://www.springframework.org/Freeware
StripesStripes is a presentation framework for building web applications using the latest Java technologies. The main driver behind Stripes is that web application development in Java is just too much work!No XML - Convention over Configuration
Good documentation (easy to learn)
Enthusiastic community
Small Community
Not as actively developed as other projects
Hard-coded URLs in ActionBeans
http://www.stripesframework.org/display/stripes/HomeFreeware
TapestryTapestry is an open-source framework for creating dynamic, robust, highly scalable web applications in Java. Tapestry complements and builds upon the standard Java Servlet API, and so it works in any servlet container or application server.Very productive once you learn it
Templates are HTML - great for designers
Lots of innovation between releases
Documentation very conceptual, rather than
pragmatic
Steep learning curve
Long release cycles - major upgrades every year
http://tapestry.apache.org/Freeware
FlexFlex is a highly productive, free open source framework for building and maintaining expressive web applications that deploy consistently on all major browsers, desktops, and operating systems.Produces Flash UI
Funded by Adobe
Has a “poster child” in Picnik
Not Search Engine Friendly
Doesn’t render HTML content well
Doesn’t print well by default
http://flex.org/java/Freeware
GrailsIt's an open-source web application framework that leverages the Groovy language and complements Java Web development. You can use Grails as a standalone development environment that hides all configuration details or integrate your Java business logic. Grails aims to make development as simple as possible and hence should appeal to a wide range of developers not just those from the Java community. Less LOC => awesome productivity
Groovy is easy to learn for Java Developers
Using Spring and Hibernate at its foundation
Not as performant as using the raw frameworks
Can be hard to sell to stakeholders who like Java
Virtually unknown outside of blogs
http://grails.org/Freeware
SeamJBoss Seam is a powerful new application framework for building next generation Web 2.0 applications by unifying and integrating technologies such as Asynchronous JavaScript and XML (AJAX), Java Server Faces (JSF), Enterprise Java Beans (EJB3), Java Portlets and Business Process Management (BPM). Full-Stack framework with CRUD Generation
Conversations with jBPM
Heavily Funded by JBoss/Red Hat
Works best on JBoss Application Server
Designed for EJB 3
http://www.jboss.com/products/seamFreeware
WicketWith proper mark-up/logic separation, a POJO data model, and a refreshing lack of XML, Apache Wicket makes developing web-apps simple and enjoyable again. Swap the boilerplate, complex debugging and brittle code for powerful, reusable components written with plain Java and HTML.Great for Java developers, not web developers
Tight binding between pages and views
Active community - support from the creators
HTML templates live next to Java code
Need to have a good grasp of OO
The Wicket Way - everything done in Java
http://wicket.apache.org/Freeware
IT Mill Toolkit
IT Mill Toolkit enables developers to build high quality browser user interfaces with Java on server. It provides a library of ready to use high-quality user interface components and defines clean framework for creating your own components.The toolkit has been used in production since year 2001 and it is shown to be suitable for building demanding business applications.Ease of use, re-usability, extensibility and meeting requirements of large enterprise application.
http://www.itmill.com/developers/Community Edition available for free download and other featured versions include pricing.
Refer : http://www.itmill.com/itmill-toolkit/licensing-and-pricing.htm

Friday, July 31, 2015

Forward Mails Based on Search Criteria

Have you ever wanted to forward all mails that matching a search expression? That option is not available through the Gmail interface but it is relatively easy to do that with a script.

An example of the script is as follow:

function forwardMail() {
  var threads = GmailApp.search("before:2009/07/01 after:2009/06/30"); // second search string.
 
  for (var i in threads) {
    var lastMsg = threads[i].getMessageCount(); //get last message
    var messages = threads[i].getMessages();
   
    var message = messages[0]; //first mail in the thread
    //var message = messages[lastMsg-1]; // last mail in the thread
    message.forward("strovek@seagate.com");
   
  }
}







Notes:

In the example above, you can use messages[0] to select the first message in a thread or messages[lastMsg-1] for the last message in a thread.  The last message will usually contains most of the replies of the threads if the participants are the same throughout the thread conversations.



To make sure you get the mails you want to forward, test the search expression in Gmail first.

Wednesday, July 15, 2015

Using MailApp.SendMail

I thought that you could only MailApp.SendMail api in Google Script with standard parameter for example:

MailApp.sendEmail(recipient, subject,body)

However, I just realize that you just need to use braces to use other advance parameters. For example to add cc, you can do the following.

function sendTestMail() 
 {
   var toList = "strovek@gmail.com"; 

   var ccList = "strovek2@outlook.com" 
   var subj = "Testing sendmail api"; 
   var bodyContent = "If you receive this mail, then the test is successful"
      + "<br><br>This is a second line"; 

    MailApp.sendEmail({to: toList, cc: ccList, subject: subj, htmlBody: bodyContent});

Thursday, October 2, 2014

Useful Windows commands

Received the following list of commands from a friend that can be run off from the Run Command Prompt:

Program Run Command
...
Accessibility Controls = access.cpl
Accessibility Wizard = accwiz
Add Hardware Wizard = hdwwiz.cpl
Add/Remove Programs = appwiz.cpl
Administrative Tools = control admintools
Adobe Acrobat ( if installed ) = acrobat
Adobe Distiller ( if installed ) = acrodist
Adobe ImageReady ( if installed ) = imageready
Adobe Photoshop ( if installed ) = photoshop
Automatic Updates = wuaucpl.cpl
Basic Media Player = mplay32
Bluetooth Transfer Wizard = fsquirt

Calculator = calc
Ccleaner ( if installed ) = ccleaner
C: Drive = c:
Certificate Manager = cdrtmgr.msc
Character Map = charmap
Check Disk Utility = chkdsk
Clipboard Viewer = clipbrd
Command Prompt = cmd
Command Prompt = command
Component Services = dcomcnfg
Computer Management = compmgmt.msc
Compare Files = comp
Control Panel = control
Create a shared folder Wizard = shrpubw

Date and Time Properties = timedate.cpl
DDE Shares = ddeshare
Device Manager = devmgmt.msc
Direct X Control Panel ( if installed ) = directx.cpl
Direct X Troubleshooter = dxdiag
Disk Cleanup Utility = cleanmgr
Disk Defragment = dfrg.msc
Disk Partition Manager = diskmgmt.msc
Display Properties = control desktop
Display Properties = desk.cpl
Display Properties (w/Appearance Tab Preselected ) = control color
Dr. Watson System Troubleshooting Utility = drwtsn32
Driver Verifier Utility = verifier

Ethereal ( if installed ) = ethereal
Event Viewer = eventvwr.msc
Files and Settings Transfer Tool = migwiz
File Signature Verification Tool = sigverif
Findfast = findfast.cpl
Firefox = firefox
Folders Properties = control folders
Fonts = fonts
Fonts Folder = fonts
Free Cell Card Game = freecell

Game Controllers = joy.cpl
Group Policy Editor ( xp pro ) = gpedit.msc
Hearts Card Game = mshearts
Help and Support = helpctr
Hyperterminal = hypertrm
Hotline Client = hotlineclient

Iexpress Wizard = iexpress
Indexing Service = ciadv.msc
Internet Connection Wizard = icwonn1
Internet Properties = inetcpl.cpl
Internet Setup Wizard = inetwiz
IP Configuration (Display Connection Configuration) = ipconfig /all
IP Configuration (Display DNS Cache Contents) = ipconfig /displaydns
IP Configuration (Delete DNS Cache Contents) = ipconfig /flushdns
IP Configuration (Release All Connections) = ipconfig /release
IP Configuration (Renew All Connections) = ipconfig /renew
IP Configuration (Refreshes DHCP & Re-Registers DNS) = ipconfig /registerdns
IP Configuration (Display DHCP Class ID) = ipconfig /showclassid
IP Configuration (Modifies DHCP Class ID) = ipconfig /setclassid

Java Control Panel ( if installed ) = jpicpl32.cpl
Java Control Panel ( if installed ) = javaws
Keyboard Properties = control keyboard

Local Security Settings = secpol.msc
Local Users and Groups = lusrmgr.msc
Logs You Out of Windows = logoff

Malicious Software Removal Tool = mrt
Microsoft Access ( if installed ) = access.cpl
Microsoft Chat = winchat
Microsoft Excel ( if installed ) = excel
Microsoft Diskpart = diskpart
Microsoft Frontpage ( if installed ) = frontpg
Microsoft Movie Maker = moviemk
Microsoft Management Console = mmc
Microsoft Narrator = narrator
Microsoft Paint = mspaint
Microsoft Powerpoint = powerpnt
Microsoft Word ( if installed ) = winword
Microsoft Syncronization Tool = mobsync
Minesweeper Game = winmine
Mouse Properties = control mouse
Mouse Properties = main.cpl
MS-Dos Editor = edit
MS-Dos FTP = ftp

Nero ( if installed ) = nero
Netmeeting = conf
Network Connections = control netconnections
Network Connections = ncpa.cpl
Network Setup Wizard = netsetup.cpl
Notepad = notepad
Nview Desktop Manager ( if installed ) = nvtuicpl.cpl

Object Packager = packager
ODBC Data Source Administrator = odbccp32
ODBC Data Source Administrator = odbccp32.cpl
On Screen Keyboard = osk
Opens AC3 Filter ( if installed ) = ac3filter.cpl
Outlook Express = msimn

Paint = pbrush
Password Properties = password.cpl
Performance Monitor = perfmon.msc
Performance Monitor = perfmon
Phone and Modem Options = telephon.cpl
Phone Dialer = dialer
Pinball Game = pinball
Power Configuration = powercfg.cpl
Printers and Faxes = control printers
Printers Folder = printers
Private Characters Editor = eudcedit

Quicktime ( if installed ) = quicktime.cpl
Quicktime Player ( if installed ) = quicktimeplayer

Real Player ( if installed ) = realplay
Regional Settings = intl.cpl
Registry Editor = regedit
Registry Editor = regedit32
Remote Access Phonebook = rasphone
Remote Desktop = mstsc
Removable Storage = ntmsmgr.msc
Removable Storage Operator Requests = ntmsoprq.msc
Resultant Set of Policy ( xp pro ) = rsop.msc

Scanners and Cameras = sticpl.cpl
Scheduled Tasks = control schedtasks
Security Center = wscui.cpl
Services = services.msc
Shared Folders = fsmgmt.msc
Sharing Session = rtcshare
Shuts Down Windows = shutdown
Sounds Recorder = sndrec32
Sounds and Audio = mmsys.cpl
Spider Solitare Card Game = spider
SQL Client Configuration = clicongf
System Configuration Editor = sysedit
System Configuration Utility = msconfig
System File Checker Utility ( Scan Immediately ) = sfc /scannow
System File Checker Utility ( Scan Once At Next Boot ) = sfc /scanonce
System File Checker Utility ( Scan On Every Boot ) = sfc /scanboot
System File Checker Utility ( Return to Default Settings) = sfc /revert
System File Checker Utility ( Purge File Cache ) = sfc /purgecache
System File Checker Utility ( Set Cache Size to Size x ) = sfc /cachesize=x
System Information = msinfo32
System Properties = sysdm.cpl

Task Manager = taskmgr
TCP Tester = tcptest
Telnet Client = telnet
Tweak UI ( if installed ) = tweakui
User Account Management = nusrmgr.cpl
Utility Manager = utilman

Volume Serial Number for C: = label
Volume Control = sndvol32
Windows Address Book = wab
Windows Address Book Import Utility = wabmig
Windows Backup Utility ( if installed ) = ntbackup
Windows Explorer = explorer
Windows Firewall = firewall.cpl
Windows Installer Details = msiexec
Windows Magnifier = magnify

Windows Management Infrastructure = wmimgmt.msc
Windows Media Player = wmplayer
Windows Messenger = msnsgs
Windows Picture Import Wizard (Need camera connected) = wiaacmgr
Windows System Security Tool = syskey
Windows Script host settings = wscript
Widnows Update Launches = wupdmgr
Windows Version ( shows your windows version ) = winver
Windows XP Tour Wizard = tourstart
Wordpad = write
Zoom Utility = igfxzoom

Tuesday, July 8, 2014

Turning on Wifi for Windows using Command line

The configuration on my notebook in the office automatically disables my wifi when I connect to our network by cable. On several occasions, the wifi dos not turn back on after I remove my PC from the docking station. I was also unable to find anything in the control panel on Windows 7 to help me do this, luckily, I found the solution from this article. The solution is shown below. An alternative way would be to right click on the network icon and click on troubleshoot problem.


Using netsh command
Get the Interface Name:
netsh interface show interface
Enable the interface:
netsh interface set interface "Interface Name" enabled
To complete the solution to your problem, you could create a shortcut, and make it run on the startup of Windows. For example, if the name of your wireless adapter in netsh is Wi-Fi, the shortcut would look like this (one line):
C:\Windows\System32\runas.exe /savecred /user:administrator "C:\Windows\System32\netsh.exe interface set interface \"Wi-Fi\" enabled"
The runas command ensures that the command is ran as administrator, which is required to bring the interface up or down. The /savecred switch will save the credentials, which might be asked the first time, but usually not after that.
Using wmc command
wmic nic get name, index
Enable NIC with index number: (eg: 7)
wmic path win32_networkadapter where index=7 call enable
Disable NIC with index number: (eg: 7)
wmic path win32_networkadapter where index=7 call disable

Wednesday, October 16, 2013

Limiting GApp search to a folder

Found this trick in a discussion on the topic. This is a feature lacking in the new search operator.

  1. Click on folder so you are only viewing within the folder you want to search
  2. The URL in your browser location bar will change to something like:
    https://drive.google.com/?ui=4&authuser=0#folders/0B6AzksONG.....
  3. Copy the text from the URL which comes after "folders/"
  4. Insert that text instead of THELONGFOLDERID into the following URL string:
    https://drive.google.com/?ui=4&authuser=0#advanced-search/q=dummy&view=2&parent=THELONGFOLDERID
  5. When you go to the URL you have just constructed, you can then use the search box to search inside that folder --- for convenience, I suggest you bookmark the URL if you do such searches often

In the example above, the url will become:

https://drive.google.com/?ui=4&authuser=0#advanced-search/q=dummy&view=2&parent=0B6AzksONG.....

I tested it using Chrome and it works and TheMathGuy used Firefox so it works for both browsers.

Thursday, December 27, 2012

Java Script to Produce Proper Capitalization

The code is as follow:

/*
* Title Caps
*
* Ported to JavaScript By John Resig - http://ejohn.org/ - 21 May 2008
* Original by John Gruber - http://daringfireball.net/ - 10 May 2008
* License: http://www.opensource.org/licenses/mit-license.php
*/
(function(){
var small = "(a|an|and|as|at|but|by|en|for|if|in|of|on|or|the|to|v[.]?|via|vs[.]?)";
var punct = "([!\"#$%&'()*+,./:;<=>?@[\\\\\\]^_`{|}~-]*)";
this.titleCaps = function(title){
var parts = [], split = /[:.;?!] |(?: |^)["Ã’]/g, index = 0;
while (true) {
var m = split.exec(title);
parts.push( title.substring(index, m ? m.index : title.length)
.replace(/\b([A-Za-z][a-z.'Õ]*)\b/g, function(all){
return /[A-Za-z]\.[A-Za-z]/.test(all) ? all : upper(all);
})
.replace(RegExp("\\b" + small + "\\b", "ig"), lower)
.replace(RegExp("^" + punct + small + "\\b", "ig"), function(all, punct, word){
return punct + upper(word);
})
.replace(RegExp("\\b" + small + punct + "$", "ig"), upper));
index = split.lastIndex;
if ( m ) parts.push( m[0] );
else break;
}
return parts.join("").replace(/ V(s?)\. /ig, " v$1. ")
.replace(/(['Õ])S\b/ig, "$1s")
.replace(/\b(AT&T|Q&A)\b/ig, function(all){
return all.toUpperCase();
});
};
function lower(word){
return word.toLowerCase();
}
function upper(word){
return word.substr(0,1).toUpperCase() + word.substr(1);
}
})();

Code is taken from:
http://ejohn.org/blog/title-capitalization-in-javascript/


In order to get use the above, create a file and place the following code and save it. You can then run it locally to automatically show you the proper capitalization of the title. Just key in the title in the text box and click the submit button, it will then display the result above. Note that the script does not work in IE, it works in Chrome and Firefox.





=====================================

<head>
</head>
<script type="text/javascript">
/*
* Title Caps
*
* Ported to JavaScript By John Resig - http://ejohn.org/ - 21 May 2008
* Original by John Gruber - http://daringfireball.net/ - 10 May 2008
* License: http://www.opensource.org/licenses/mit-license.php
*/

(function(){
var small = "(a|an|and|as|at|but|by|en|for|if|in|of|on|or|the|to|v[.]?|via|vs[.]?)";
var punct = "([!\"#$%&'()*+,./:;<=>?@[\\\\\\]^_`{|}~-]*)";

this.titleCaps = function(title){
var parts = [], split = /[:.;?!] |(?: |^)["Ã’]/g, index = 0;

while (true) {
var m = split.exec(title);

parts.push( title.substring(index, m ? m.index : title.length)
.replace(/\b([A-Za-z][a-z.'Õ]*)\b/g, function(all){
return /[A-Za-z]\.[A-Za-z]/.test(all) ? all : upper(all);
})
.replace(RegExp("\\b" + small + "\\b", "ig"), lower)
.replace(RegExp("^" + punct + small + "\\b", "ig"), function(all, punct, word){
return punct + upper(word);
})
.replace(RegExp("\\b" + small + punct + "$", "ig"), upper));

index = split.lastIndex;

if ( m ) parts.push( m[0] );
else break;
}

return parts.join("").replace(/ V(s?)\. /ig, " v$1. ")
.replace(/(['Õ])S\b/ig, "$1s")
.replace(/\b(AT&T|Q&A)\b/ig, function(all){
return all.toUpperCase();
});
};

function lower(word){
return word.toLowerCase();
}

function upper(word){
return word.substr(0,1).toUpperCase() + word.substr(1);
}
})();
</script>
<body>
<br />
<script>
function displayRslt()
{
var tmp;
var myTextFld;

try
{
  myTextFld = document.getElementById("tFld");

  if(myTextFld.value != "")
   {
     document.getElementById("tDisp").innerHTML=titleCaps(myTextFld.value);
   }
   else
     document.getElementById("tDisp").innerHTML="Nothing entered";
 }
catch(err)
  {
    document.getElementById("tDisp").innerHTML="error caught "+err.message;
   }
}
</script>
<p id="tDisp">Paragraph</p><br />
<form name="tForm" action="" method="GET">
Input values: <input type="text" id="tFld" value=""><br />
<Input type="button" name="submit" value="submit" onClick="displayRslt()">
</form>
</body>









======================================










Friday, November 30, 2012

JDBC Connection String to Use LDAP


If LDAP allows anonymous.
String ldapHost    = "ldap-server:389";
String context     = ",dc=nl,dc=abnamro,dc=com";
 
String serviceName = "mts-a-de-grid";
String user        = "aldo";
String pass        = "aldo";
String url         = "jdbc:oracle:thin:@ldap://" + ldapHost + "/" + instance + ldap_context;
 
OracleDataSource o = new OracleDataSource();
 
o.setUser(user);
o.setPassword(password);
o.setURL(url);
 
Connection conn = o.getConnection();

If authentication is required:
String url = "jdbc:oracle:thin:@ldap://ldap-server:389/CN=Admin,O=COHERIS,C=FR";
 
 
Properties prop = new Properties();
prop.put("java.naming.security.authentication", "simple");
prop.put("java.naming.security.principal","CN=Admin,O=COHERIS,C=FR");
prop.put("java.naming.security.credentials", "password");
 
OracleDataSource ods = new OracleDataSource();
ods.setURL(url);
ods.setConnectionProperties(prop);

Reference:
  Oracle Forum

Friday, October 19, 2012

sudo: /etc/sudoers is mode 0640, should be 0440

If you encounter the following error, it is likely because you ran the su command while your current folder is /etc and the sudo is in the same folder.

Reference:

http://askubuntu.com/questions/189818/how-to-repair-sudo-etc-sudoers-is-mode-0640-should-be-0440

Wednesday, October 17, 2012

Retrieving JDBC version information

The following is how you can retrieve the jdbc version:


import oracle.jdbc.OracleConnection;
import oracle.jdbc.pool.OracleDataSource;
import java.sql.SQLException;
import java.sql.DatabaseMetaData;
import java.util.Properties;
 
 
public class JDBCVersionInfo {
   
  public static void main(String[] args) {
    try {
      // Set up user connection properties
      Properties prop = new Properties();
      prop.setProperty("user","hr");
      prop.setProperty("password","password");
       
      // open the connection
      OracleDataSource ods = new OracleDataSource();
      ods.setConnectionProperties(prop);
      ods.setURL("jdbc:oracle:thin:@//prod:1521/proddb");
      OracleConnection ocon = (OracleConnection)ods.getConnection();
       
      DatabaseMetaData dbmd = ocon.getMetaData();
       
      System.out.println("Driver Name: " + dbmd.getDriverName());
      System.out.println("Driver Version: " + dbmd.getDriverVersion());
     
       
    } catch(SQLException e) {
      System.out.println(e.getMessage());
    }
  }
}
 
Reference from the following url: