Saturday, February 21, 2015

DERBY

Set Environment Variable
Path=C:\Program Files\Java\jdk1.7.0_04\db\bin;
DERBY_HOME= C:\Program Files\Java\jdk1.7.0_67\db
CLASSPATH=%DERBY_HOME%\lib\derby.jar;%DERBY_HOME%\lib\derbytools.jar;.
--------------------------------
VERIFY DERBY
 --------------------------------
sysinfo.bat
--------------------------------
START NETWORK SERVER
--------------------------------
startNetworkServer.bat
--------------------------------
START Command Line Client
--------------------------------
ij
java  org.apache.derby.tools.ij -p ij.properties
--------------------------------
NOTE: EVERY COMMAND END WITH SEMICOLON (;)
--------------------------------
HELP in ij
--------------------------------
ij>help;
ij>SHOW CONNECTIONS;
ij>SHOW TABLES;
ij>SHOW TABLES IN APP;
ij>DESCRIBE APP.CUSTOMERS;
ij>DISCONNECT;
ij>EXIT;
ij>DROP TABLE [TableName]
ij>SET SCHEMA APP
--------------------------------
CREATE & CONNECT NETWORK DATABASE
--------------------------------
ij>connect 'jdbc:derby://localhost:1527/MyDB;create=true;user=APP;password=APP';
ij>connect 'jdbc:derby://localhost:1527/MyDB;user=APP;password=APP';
ij>connect 'jdbc:derby:MyDB;user=APP;password=APP';
--------------------------------
ij command line tool with default settings from file (ij.properties)
--------------------------------
ij.user=APP
ij.database=MyDB;create=true;
ij.protocol=jdbc:derby:
derby.connection.requireAuthentication=true
derby.user.APP=APP
--------------------------------
Loading properties file
--------------------------------
ij>ij -p ij.properties
java org.apache.derby.tools.ij -p ij.properties

java -cp "target/dependency/*"  org.apache.derby.tools.ij -p ij.properties
--------------------------------
CREATE and LOAD database from SQL  File
--------------------------------
ij>run 'create_classicmodels.sql';
ij>run 'load_classicmodels.sql';
java org.apache.derby.tools.ij my_file.sql

--------------------------------
Derby Maven
--------------------------------
mvn dependency:copy-dependencies
--------------------------------
Derby in POM
--------------------------------
 <?xml version="1.0" encoding="UTF-8"? >
 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" >
     <modelVersion >4.0.0 </modelVersion >
     <groupId >com.mastertheboss </groupId >
     <artifactId >EclipseJPAExample </artifactId >
     <version >1.0-SNAPSHOT </version >
     <repositories >
         <repository >
             <id >EclipseLink Repo </id >
             <url >http://download.eclipse.org/rt/eclipselink/maven.repo </url >
             <name >EclipseLink Repo </name >
         </repository >
     </repositories >
     <dependencies >
         <dependency >
             <groupId >org.apache.derby </groupId >
             <artifactId >derby </artifactId >
             <version >10.8.2.2 </version >
         </dependency >
         <dependency >
             <groupId >org.apache.derby </groupId >
             <artifactId >derbytools </artifactId >
             <version >10.8.2.2 </version >
         </dependency >
         <dependency >
             <groupId >org.eclipse.persistence </groupId >
             <artifactId >eclipselink </artifactId >
             <version >2.2.1 </version >
         </dependency >
         <dependency >
             <groupId >org.eclipse.persistence </groupId >
             <artifactId >javax.persistence </artifactId >
             <version >2.0.3 </version >
         </dependency > 
     </dependencies >
 </project >
--------------------------------
Help URL
--------------------------------
http://zetcode.com/db/apachederbytutorial/
--------------------------------
Sample
--------------------------------
ij>connect 'jdbc:derby://localhost:1527/myDB;user=me;password=mine';
ij>create table foo (id integer, name varchar(20));
ij>insert into foo values (1, 'derby');
ij>insert into foo values (2, 'derby plug-ins');
ij>disconnect;
ij>exit;
Derby Embedded Server
ij>connect 'jdbc:derby:myDB;create=true;user=me;password=mine';

Saturday, February 7, 2015

Save, Restore, Repair MBR using MBRwizard CLI

  • Download MBRwizard CLI from : Click Here
  • For MBRWizard examples : Click Here
  • Save below script as 1mbrwiz.cmd and Execute  It:

REM------------- BEGIN 1mbrwiz.cmd codes -----------------------

@echo off

rem 1mbrwiz.cmd
rem To backup the MBR using %MBRWIZFILE%

setlocal
%~d0
cd "%~dp0"
set OPTION=mbr
set MBRWIZFILE=mbrwiz64.exe
if not exist %MBRWIZFILE% goto _ERROR1

:MENU
title MBRWizard Menu
set _choice=
cls
echo.
echo *********************************************
echo Please select which MBRWizard options to run
echo *********************************************
echo.
echo 1 List MBR entries
echo 2 Hides the Partition number
echo 3 Unhides the Partition number
echo 4 Activates the Partition
echo 5 De-activates the Partition number
echo 6 Deletes the partition
echo 7 Wipes the MBR or wipes the first 63 sectors of disk
echo 8 Saves the MBR to filename
echo 9 Reads and restores the Disk MBR from filename
echo 10 Shows contents of an existing MBR backup file
echo 11 Sort MBR Entries by disk location
echo 12 Repair MBR for Win7 OS for input disk
echo 13 Writes detailed disk and partition information

echo.
echo Press [ENTER] to exit
echo.
echo.
set /p _choice="Enter choice number: "
echo.
if "%_choice%" == "" goto EXIT
cls
if "%_choice%" == "1" goto ListMBR
if "%_choice%" == "2" goto HidePartition
if "%_choice%" == "3" goto UnhidePartition
if "%_choice%" == "4" goto ActivatePartition
if "%_choice%" == "5" goto InactivatePartition
if "%_choice%" == "6" goto DeletePartition
if "%_choice%" == "7" goto WipeMBR
if "%_choice%" == "8" goto SaveMBR
if "%_choice%" == "9" goto RestoreMBR
if "%_choice%" == "10" goto ShowMBR
if "%_choice%" == "11" goto SortMBR
if "%_choice%" == "12" goto RepairMBR
if "%_choice%" == "13" goto Writesini


:Writesini
title MBRWizard -     Writes detailed disk and partition information to filename in a .ini format.
set DriveNumber=
set Filename=
echo.
echo Please enter the HDD to use ("0" for 1st, "1" for 2nd, ...)
echo.
echo Press [ENTER] to abort.
echo.
set /p DriveNumber="Enter drive number: "
if "%DriveNumber%" == "" goto EXIT
set Filename=hd%DriveNumber%.ini
echo.
echo Running: %MBRWIZFILE% /disk=%DriveNumber% /Writeini /filename=%Filename%
echo.
%MBRWIZFILE% /disk=%DriveNumber% /Writeini /filename=%Filename%
if "%errorlevel%" == "0" goto SUCCESS
echo.
goto EXIT

:RepairMBR
title MBRWizard - Repair MBR for Win7 OS for input disk
echo.
set DriveNumber=
echo.
echo Please enter the HDD to use ("0" for 1st, "1" for 2nd, ...)
echo.
echo Press [ENTER] to abort.
echo.
set /p DriveNumber="Enter drive number: "
echo.
if "%DriveNumber%" == "" goto EXIT
echo.
echo Running: %MBRWIZFILE% /disk=%DriveNumber% /repair=win7
echo.
%MBRWIZFILE% /disk=%DriveNumber% /repair=win7
if "%errorlevel%" == "0" goto SUCCESS
echo.
goto EXIT

:ListMBR
title MBRWizard - List MBR entries
echo.
echo Running: %MBRWIZFILE% /list
echo.
%MBRWIZFILE% /list
echo.
goto EXIT

:HidePartition
title MBRWizard - Hides the Partition number
set DriveNumber=
set PartitionNumber=
echo.
echo Please enter the HDD to use ("0" for 1st, "1" for 2nd, ...)
echo.
echo Press [ENTER] to abort.
echo.
set /p DriveNumber="Enter drive number: "
if "%DriveNumber%" == "" goto EXIT
echo.
echo Please enter the partition ID to hide ("0" for 1st,
echo "1" for 2nd, ... or "*" for all).
echo.
echo Press [ENTER] to abort.
echo.
set /p PartitionNumber="Enter partition number to hide: "
if "%PartitionNumber%" == "" goto EXIT
echo.
cls
echo Running: %MBRWIZFILE% /disk=%DriveNumber% /part=%PartitionNumber% /hide /list
echo.
%MBRWIZFILE% /disk=%DriveNumber% /part=%PartitionNumber% /hide /list
if "%errorlevel%" == "0" goto SUCCESS
echo.
goto EXIT

:UnhidePartition
title MBRWizard - Unhides the Partition number
set DriveNumber=
set PartitionNumber=
echo.
echo Please enter the HDD to use ("0" for 1st, "1" for 2nd, ...)
echo.
echo Press [ENTER] to abort.
echo.
set /p DriveNumber="Enter drive number: "
if "%DriveNumber%" == "" goto EXIT
echo.
echo Please enter the partition ID to unhide ("0" for 1st,
echo "1" for 2nd, ...; "*" for all).
echo.
echo Press [ENTER] to abort.
echo.
set /p PartitionNumber="Enter partition number: "
if "%PartitionNumber%" == "" goto EXIT
echo.
cls
echo Running: %MBRWIZFILE% /disk=%DriveNumber% /part=%PartitionNumber% /unhide  /list
echo.
%MBRWIZFILE% /disk=%DriveNumber% /part=%PartitionNumber% /unhide /list
if "%errorlevel%" == "0" goto SUCCESS
echo.
goto EXIT

:ActivatePartition
title MBRWizard - Activates the Partition
set DriveNumber=
set PartitionNumber=
echo.
echo Please enter the HDD to use ("0" for 1st, "1" for 2nd, ...)
echo If you do not know which HDD to choose, please enter
echo 'bm' to call the bootmenu.
echo.
echo Press [ENTER] to abort.
echo.
set /p DriveNumber="Enter drive number: "
if "%DriveNumber%" == "" goto EXIT
if "%DriveNumber%" == "bm" goto BOOTMENU
echo.
echo Please enter the partition ID to activate ("0" for 1st, "1" for 2nd, ...).
echo.
echo Press [ENTER] to abort.
echo.
set /p PartitionNumber="Enter partition number: "
if "%PartitionNumber%" == "" goto EXIT
echo.
cls
echo Running: %MBRWIZFILE% /disk=%DriveNumber% /part=%PartitionNumber% /active /list
echo.
%MBRWIZFILE% /disk=%DriveNumber% /part=%PartitionNumber% /active /list
if "%errorlevel%" == "0" goto SUCCESS
echo.
goto EXIT

:InactivatePartition
title MBRWizard - De-activates the partition number
set DriveNumber=
set PartitionNumber=
echo.
echo Please enter the HDD to use ("0" for 1st, "1" for 2nd, ...)
echo.
echo Press [ENTER] to abort.
echo.
set /p DriveNumber="Enter drive number: "
if "%DriveNumber%" == "" goto EXIT
echo.
echo Please enter the partition ID to deactivate ("0" for 1st,
echo "1" for 2nd, ...; "*" for all).
echo.
echo Press [ENTER] to abort.
echo.
set /p PartitionNumber="Enter partition number: "
if "%PartitionNumber%" == "" goto EXIT
echo.
cls
echo Running: %MBRWIZFILE% /disk=%DriveNumber% /part=%PartitionNumber% /inactive /list
echo.
%MBRWIZFILE% /disk=%DriveNumber% /part=%PartitionNumber% /inactive /list
if "%errorlevel%" == "0" goto SUCCESS
echo.
goto EXIT

:DeletePartition
title MBRWizard - Deletes the partition
set DriveNumber=
set PartitionNumber=
echo.
echo Please enter the HDD to use ("0" for 1st, "1" for 2nd, ...)
echo.
echo Press [ENTER] to abort.
echo.
set /p DriveNumber="Enter drive number: "
if "%DriveNumber%" == "" goto EXIT
echo.
echo Please enter the partition ID to delete ("0" for 1st, "1" for 2nd, ...).
echo.
echo Press [ENTER] to abort.
echo.
set /p PartitionNumber="Enter partition number: "
if "%PartitionNumber%" == "" goto EXIT
echo.
cls
echo Running: %MBRWIZFILE% /disk=%DriveNumber% /part=%PartitionNumber% /del /list
echo.
%MBRWIZFILE% /disk=%DriveNumber% /part=%PartitionNumber% /del /list
goto EXIT

:WipeMBR
title MBRWizard - Wipes the MBR or wipes the first 63 sectors of disk
set DriveNumber=
set OPTION=
echo.
echo Please enter the HDD to use ("0" for 1st, "1" for 2nd, ...)
echo.
echo Press [ENTER] to abort.
echo.
set /p DriveNumber="Enter drive number: "
if "%DriveNumber%" == "" goto EXIT
echo.
echo Please enter "1" for wipes the MBR, "2" for wipes of first 63 sectors of disk.
echo.
echo Press [ENTER] to abort.
echo.
set /p OPTION="Enter option: "
if "%OPTION%" == "" goto EXIT
echo.
cls
echo Running: %MBRWIZFILE% /disk=%DriveNumber% /wipe=%OPTION% /list
echo.
%MBRWIZFILE% /disk=%DriveNumber% /wipe=%OPTION% /list
goto EXIT

:SaveMBR
title MBRWizard - Save the MBR to filename
set DriveNumber=
set Filename=
echo.
echo Please enter the HDD to use ("0" for 1st, "1" for 2nd, ...)
echo.
echo Press [ENTER] to abort.
echo.
set /p DriveNumber="Enter drive number: "
if "%DriveNumber%" == "" goto EXIT
echo.
echo Please enter filename to save (eg: hd0.mbr)
echo.
echo Press [ENTER] to abort.
echo.
set /p Filename="Enter filename: "
if "%Filename%" == "" goto EXIT
echo.
cls
echo Running: %MBRWIZFILE% /disk=%DriveNumber% /save=MBR /filename=%Filename%
echo.
%MBRWIZFILE% /disk=%DriveNumber% /save=MBR /filename=%Filename%
echo.
goto EXIT

:RestoreMBR
title MBRWizard - Reads and restores the Disk MBR from filename
set DriveNumber=
set Filename=
echo.
echo Please enter the HDD to use ("0" for 1st, "1" for 2nd, ...)
echo.
echo Press [ENTER] to abort.
echo.
set /p DriveNumber="Enter drive number: "
if "%DriveNumber%" == "" goto EXIT
echo.
echo Please enter filename to restore (eg: hd0.mbr)
echo.
echo Press [ENTER] to abort.
echo.
set /p Filename="Enter filename: "
if "%Filename%" == "" goto EXIT
echo.
cls
echo Running: %MBRWIZFILE% /disk=%DriveNumber% /restore=MBR /filename=%Filename% /list
echo.
%MBRWIZFILE% /disk=%DriveNumber% /restore=MBR /filename=%Filename% /list
echo.
goto EXIT

:ShowMBR
title MBRWizard - Shows contents of an existing MBR backup file
set Filename=
echo.
echo Please enter filename to display (eg: hd0.mbr)
echo.
echo Press [ENTER] to abort.
echo.
set /p Filename="Enter filename: "
if "%Filename%" == "" goto EXIT
echo.
cls
echo Running: %MBRWIZFILE%  /show=file /filename=%Filename%
echo.
%MBRWIZFILE% /show=file /filename=%Filename%
goto EXIT

:SortMBR
title MBRWizard - Sort MBR Entries by disk location
echo.
echo Running: %MBRWIZFILE% /issorted /list
echo.
%MBRWIZFILE% /issorted /list
if "%errorlevel%" == "1" goto NotSort
echo The partition entries in the MBR are already sorted.
goto EXIT

:NotSort
set INPUT=
echo The partition entries in the MBR are not sorted.
echo Do you want MBRWizard to sort the partition entries ?
echo.
echo Press [ENTER] to abort.
echo.
set /p INPUT="Enter [y]es or [n]o: "
echo.
if /I "%INPUT%" == "" goto EXIT
if /I "%INPUT%" == "n" goto EXIT
cls
echo Running: %MBRWIZFILE% /sort /list
echo.
%MBRWIZFILE% /sort /list
if "%errorlevel%" == "0" goto SUCCESS
goto EXIT

:SUCCESS
echo.
echo Operation completed successfully.
echo.
goto EXIT

:EXIT
set _exit=
echo.
echo Do you want to exit MBRWiz ?
echo.
set /p _exit="Enter [y]es or [n]o: "
if /I "%_exit%" == "" goto EXIT
if /I "%_exit%" == "n" goto MENU
if /I "%_exit%" == "y" goto END


:BOOTMENU
cls
echo Running: %MBRWIZFILE% /bootmenu
echo.
%MBRWIZFILE% /bootmenu
echo.
if "%errorlevel%" == "0" goto SUCCESS
echo.
goto EXIT

:_ERROR1
echo.
echo ERROR: %MBRWIZFILE% file not found
echo Kindly check if you have downloaded the MBRWiz from
echo http://www.mbrwizard.com
goto END

:END
endlocal

REM ------------- END 1mbrwiz.cmd codes --------------------------