Problem in enc/dec with DSA-Elgamal (keys generated using GNUPG utility)
Hi all
Facing the problem in encryption/decryption using DSA-Elgamal (keys generated using GNUPG utility)
Steps followed
Generated a key pair using DSA and Elgamal (default) form GNUPG utility (size 1024)
Placed generated keys pubring.gpg & secring.gpg in the source directory where the code is executing but am getting the error
D:\test>c:\jdk\bin\java BouncyCastlePGPTest
Creating a temp file...
Temp file created at
D:\test\pgp
Reading the temp file to make sure that the bits were written
the message I want to encrypt
Get Public Key
Key Strength = 1024
Algorithm = 17
mohankumar (start) <[email protected]>
Key Count = 1
In Ecrypt File
creating comData...
comData created...
using PGPEncryptedDataGenerator...
111...
java.lang.IllegalArgumentException: passed in key not an encryption key!f
D:\test>
but the same code works fine if we try to encrypt using RSA generated keys
D:\test>c:\jdk\bin\java BouncyCastlePGPTest
Creating a temp file...
Temp file created at
D:\test\pgp
Reading the temp file to make sure that the bits were written
the message I want to encrypt
Get Public Key
Key Strength = 1024
Algorithm = 1
sriganesh (sriganesh) <[email protected]>
Key Count = 1
In Ecrypt File
creating comData...
comData created...
using PGPEncryptedDataGenerator...
used PGPEncryptedDataGenerator...
wrote bOut to byte array...
Reading the encrypted file
-----BEGIN PGP MESSAGE-----
Version: BCPG v1.31
hIwD7qqzP41CKpUBBACOnQE265ud3AuJ8zGx9TjUFyeSwZH+PZJhjGLBTkI7gKdh
/hIF1u/sCzubw+9Mt8dbS0V2uHiqQgkCHAYIQKoVmiN65s8sUsIS0q3cTtBudUnd
xIEiyegtvB8LEpzldU/XrSglh8h6MdhhcPql46BG+0vs6p/bUAOygNv5e/DGzck2
1wNvc2/u2ffBgEP4qfrJUcF9OlvVAm03aB0S6gP8cH4LVdo5K9Bwu3d71qNKsryP
mML16rkA
=lfxf
-----END PGP MESSAGE-----
Decrypted Data= the message I want to encrypt
no message integrity check
Code As follows
import java.io.BufferedReader;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.security.NoSuchProviderException;
import java.security.SecureRandom;
import java.security.Security;
import org.bouncycastle.bcpg.ArmoredOutputStream;
import org.bouncycastle.jce.provider.BouncyCastleProvider;
import org.bouncycastle.openpgp.PGPCompressedDataGenerator;
import org.bouncycastle.openpgp.PGPEncryptedDataGenerator;
import org.bouncycastle.openpgp.PGPException;
import org.bouncycastle.openpgp.PGPLiteralData;
import org.bouncycastle.openpgp.PGPPublicKey;
import org.bouncycastle.openpgp.PGPPublicKeyRing;
import org.bouncycastle.openpgp.PGPUtil;
import org.bouncycastle.openpgp.*;
import java.util.Iterator;
public class BouncyCastlePGPTest {
private static PGPPrivateKey findSecretKey(
InputStream keyIn,
long keyID,
char[] pass)
throws IOException, PGPException, NoSuchProviderException {
PGPSecretKeyRingCollection pgpSec = new PGPSecretKeyRingCollection(PGPUtil.getDecoderStream(keyIn));
PGPSecretKey pgpSecKey = pgpSec.getSecretKey(keyID);
if (pgpSecKey == null) {
return null;
return pgpSecKey.extractPrivateKey(pass, "BC");
private static void decryptFile(InputStream in, InputStream keyIn, char[] passwd) throws Exception
in = PGPUtil.getDecoderStream(in);
try {
PGPObjectFactory pgpF = new PGPObjectFactory(in);
PGPEncryptedDataList enc;
Object o = pgpF.nextObject();
// the first object might be a PGP marker packet.
if (o instanceof PGPEncryptedDataList)
enc = (PGPEncryptedDataList)o;
else
enc = (PGPEncryptedDataList)pgpF.nextObject();
// find the secret key
Iterator it = enc.getEncryptedDataObjects();
PGPPrivateKey sKey = null;
PGPPublicKeyEncryptedData pbe = null;
while (sKey == null && it.hasNext())
pbe = (PGPPublicKeyEncryptedData)it.next();
sKey = findSecretKey(keyIn, pbe.getKeyID(), passwd);
if (sKey == null)
throw new IllegalArgumentException("secret key for message not found.");
InputStream clear = pbe.getDataStream(sKey, "BC");
PGPObjectFactory plainFact = new PGPObjectFactory(clear);
Object message = plainFact.nextObject();
if (message instanceof PGPCompressedData)
PGPCompressedData cData = (PGPCompressedData)message;
PGPObjectFactory pgpFact = new PGPObjectFactory(cData.getDataStream());
message = pgpFact.nextObject();
if (message instanceof PGPLiteralData)
PGPLiteralData ld = (PGPLiteralData)message;
FileOutputStream fOut = new FileOutputStream(ld.getFileName());
InputStream unc = ld.getInputStream();
int ch;
System.out.print("\n\n\nDecrypted Data= ");
while ((ch = unc.read()) >= 0)
System.out.print(""+(char)ch);
fOut.write(ch);
System.out.println("\n\n\n");
else if (message instanceof PGPOnePassSignatureList)
throw new PGPException("encrypted message contains a signed message - not literal data.");
else
throw new PGPException("message is not a simple encrypted file - type unknown.");
if (pbe.isIntegrityProtected())
if (!pbe.verify())
System.err.println("message failed integrity check");
} else
System.err.println("message integrity check passed");
else
System.err.println("no message integrity check");
catch (PGPException e) {
System.err.println(e);
if (e.getUnderlyingException() != null) {
e.getUnderlyingException().printStackTrace();
public static void main(String[] args) {
// the keyring that holds the public key we're encrypting with
String publicKeyFilePath = "D:\\test\\pubring.gpg"; //D:\\test\\pubring.pkr;
// init the security provider
Security.addProvider(new BouncyCastleProvider());
try {
System.out.println("Creating a temp file...");
// create a file and write the string to it
File outputfile = new File("pgp");//File.createTempFile("pgp", null);
FileWriter writer = new FileWriter(outputfile);
writer.write("the message I want to encrypt".toCharArray());
writer.close();
System.out.println("Temp file created at ");
System.out.println(outputfile.getAbsolutePath());
System.out.println("Reading the temp file to make sure that the bits were written\n----------------------------");
BufferedReader isr = new BufferedReader(new FileReader(outputfile));
String line = "";
while ((line = isr.readLine()) != null) {
System.out.println(line + "\n");
// read the key
FileInputStream in = new FileInputStream(publicKeyFilePath);
PGPPublicKey key = readPublicKey(in);
// find out a little about the keys in the public key ring
System.out.println("Key Strength = " + key.getBitStrength());
System.out.println("Algorithm = " + key.getAlgorithm());
int count = 0;
for (java.util.Iterator iterator = key.getUserIDs(); iterator.hasNext();) {
count++;
System.out.println((String)iterator.next());
System.out.println("Key Count = " + count);
// create an armored ascii file
FileOutputStream out = new FileOutputStream(outputfile.getAbsolutePath() + ".asc");
// encrypt the file
encryptFile(outputfile.getAbsolutePath(), out, key);
System.out.println("Reading the encrypted file\n----------------------------");
BufferedReader isr2 = new BufferedReader(new FileReader(new File(outputfile.getAbsolutePath() + ".asc")));
String line2 = "";
while ((line2 = isr2.readLine()) != null) {
System.out.println(line2);
//FileInputStream in = new FileInputStream(args[1]);
FileInputStream in2 = new FileInputStream("d:\\test\\pgp.asc");
FileInputStream keyIn = new FileInputStream("d:\\test\\secring.gpg");
decryptFile(in2, keyIn, "test123".toCharArray());
} catch (PGPException e) {
System.out.println(e.toString());
System.out.println(e.getUnderlyingException().toString());
} catch (Exception e) {
System.out.println(e.toString());
private static PGPPublicKey readPublicKey(InputStream in) throws IOException {
System.out.println("Get Public Key");
try {
PGPPublicKeyRing pgpPub = new PGPPublicKeyRing(in);
Iterator itr = pgpPub.getPublicKeys();
PGPPublicKey pk = null;
return pgpPub.getPublicKey();
} catch (IOException io) {
System.out.println("readPublicKey() threw an IOException");
System.out.println(io.toString());
throw io;
private static void encryptFile(String fileName, OutputStream out, PGPPublicKey encKey)
// throws IOException, NoSuchProviderException, PGPException
try {
System.out.println("In Ecrypt File");
out = new ArmoredOutputStream(out);
ByteArrayOutputStream bOut = new ByteArrayOutputStream();
System.out.println("creating comData...");
// get the data from the original file
PGPCompressedDataGenerator comData = new PGPCompressedDataGenerator(PGPCompressedDataGenerator.ZIP);
PGPUtil.writeFileToLiteralData(comData.open(bOut), PGPLiteralData.BINARY, new File(fileName));
comData.close();
System.out.println("comData created...");
System.out.println("using PGPEncryptedDataGenerator...");
// object that encrypts the data
PGPEncryptedDataGenerator cPk = new PGPEncryptedDataGenerator(PGPEncryptedDataGenerator.CAST5, new SecureRandom(), "BC");
cPk.addMethod(encKey);
System.out.println("used PGPEncryptedDataGenerator...");
// take the outputstream of the original file and turn it into a byte array
byte[] bytes = bOut.toByteArray();
System.out.println("wrote bOut to byte array...");
// write the plain text bytes to the armored outputstream
OutputStream cOut = cPk.open(out, bytes.length);
cOut.write(bytes);
// cOut.close();
cPk.close();
out.close();
} catch (IOException ex) {
System.out.println("IOException\t" +ex.toString());
} catch (NoSuchProviderException ex1) {
System.out.println("NoSuchProviderException\t" +ex1.toString());
} catch (PGPException ex2) {
System.out.println("PGPException\t" +ex2.toString());
}
First - you're responding to a year-old message. I doubt the OP is still around.
Second - DSA is a Digital Signature Algorithm. The error tells you exactly what the problem is - DSA is not an encryption algorithm, and can't be used as one.
Grant
Similar Messages
-
when sending email through yahoo account , i cant upload any attachment with email, a sign of uploading lasts forever without uploading the file.
this issue do not happen with hotmail account or when using IE to browse Yahoo account.Install ClamXav and run a scan with that. It should pick up any trojans.
17" 2.2GHz i7 Quad-Core MacBook Pro 8G RAM 750G HD + OCZ Vertex 3 SSD Boot HD
Got problems with your Apple iDevice-like iPhone, iPad or iPod touch? Try Troubleshooting 101 -
Problem with Chroma/Lume Keys while using Drop Shadows
I have been using the box now for almost two years and I still am getting problems with green/blue/purples artifacts showing up after a chroma/luma key has been applied with a drop shadow. The artifacts do not show up under a preview but only when the sequence has been rendered. As soon as I take the drop shadow off, the artifacts go away. This is happening with both still graphics with or without Alphas and green/blue screen video. Please help, am I just missing something or is there a work around that I could be using.
Thanks,
Alexc'mon, Bogie - tell us what you really feel - don't hold back... < </div>
Oh, Patrick, buddy, I am so totally torqued out of shape today. Don't get me started. Too late. FCP's insane render handler is dropping my files, seemingly at random. The nests, Motion and LiveType material are not rendering in the correct order which makes the effects all wonky.
I add drop shadows in the last stage and FCP just ain't holding it together. I get glitches. And then I keep getting these Media Offline notices because FCP cant' track the render files that are actually in use in the upstream nests.
I'll certainly admit a likely a user error. I just don't know what it could be. I've somehow told FCP to destroy its children.
bogiesan -
Activate problem CS6 master collection with original product key
Hello,
I have an original version of the Adobe CS6 master collection with a original product key. I use this version now or more than one year on my Imac with version Yosemite 10.10.2.
The last days i have the problem that my product key is not valid? How is that possible??
I re enter the product key for a lot of times but i can't reactievat my product.
Please help?
Arjan.Error "The serial number is not valid for this product" | Creative Suite
-
Problem update nokia 5800 with my product key
hi all,
like subject i've a problem with my nokia 5800.I can't do the update for my nokia because for my code 0596011 isn't avaible the upgrade to versione v40...i would to know when i can do this upgrade and if i have to attend a lot...thanks for attention...bye all...Latest available software for Nokia 5800 XpressMusic, product code 0596011
Version: 31.0.101
/t5/Software-Updates/TOP-questions-about-Software-Updates-start-here/td-p/186925
/t5/Software-Updates/3-months-down-the-line-still-no-V-40-update-for-my-5800XM/td-p/655711
jje -
Problem in MRP planning with user exit key
Hi All,
I have a requirement like this..
we have 1000 FG in our plant.. out of which they want to plan only 250 FG's through MRP run collectively...when they do MRP run system should plan only these 250 FG's and also down level materials ( components ) of these 250 FG's ..
So I proposed to use user exit key in MD01 screen by activating user exit M61X0001 and these 250 FG 's are identified with a separate MRP group in material master and developed enhancement..
But when I do MRP run in MD01 with this user exit key, system only planning those 250 FG's but not planning down level materials or components of these 250 FG's.. is this standard behavior.. can somebody guide me how solve this issue..
Thanks
KumarHi Kumar,
You can use either MRP Type, MRP Controller, MRP Group in this user exit to control the MRP run. For these set of Materials you have to assign any of same value or at least differentiate these material from other material. Then only you can control the MRP by using this user exit even though if you use different MRP Group and MRP Controller. In User Exit, you may have to add your dependent material's MRP Group/MRP Controller. Make sure that these set of materials are different than all other materials.
If you don't have any plan to run MRP for other materials then as per Ajit suggestion you make that material's MRP type as "ND". But, in your business case they may want to activate the MRP for all the material not now but may be latter.
Thanks -
Problem to synchronize Mac with IPad and Iphone by using ICloud
I have installed Lion on my Mac Book and updated to 10.7.4. / and I bought the new IPhone und the new IPad. >> The synchronization (Mails/Contacts) between IPad and IPhone via iCloud is running very well. But the synchronizsation via iCloud between my Mac and IPad and IPhone for Mails and Contacts is not running. I checked the installation of iCloud on my Mac, it's installed.
Who can help me? Thank you in advance!Welcome to the Apple Community.
If you are sure that everything is set up correctly and your contacts are in the iCloud group, you might try unchecking contact syncing in the iCloud settings, restarting your device and then re-enabling contact syncing. -
XCode: How can I use dictionary controllers for 2 dict's with a common key?
I have two dictionaries, both with the same key. Using Interface Builder I can build for each dictionary a two-column table, but I did not find out how to connect their keys so that selecting a line in one table automatically selects the corresponding line in the other table.
Does there exist a binding between the two controllers that solves the problem? If so, how can it be established?
(First I tried to use only ONE table - with 3 columns. This appeared to me the best way. But again I could not establish the appropriate binding.)Hans,
You may want to post your question in the following group.
http://discussions.apple.com/forum.jspa?forumID=727 -
I can't install acrobat with my license key
I can't install acrobat with my license key, but use it to install photoshop and illustrator is ok.
what should i do next?
how do i contact with technical team?What system are you on?
iOS 10.8.3
What version orf Acrobat?
7.0.0.324
Are there otehr versions of Adobe products already on teh system?
Photoshop
Illustrator
Adobe Reader
Flash
After Effect
Bridge
Are there any specific error messages?
No, it just said my license is wrong, but in other adobe products is OK.
This license is supplied by my college, each student has their own unique license key.
But only me has this problem.
You need to provide more details. -
Problem in Creating a jar file using java.util.jar and deploying in jboss 4
Dear Techies,
I am facing this peculiar problem. I am creating a jar file programmatically using java.util.jar api. The jar file is created but Jboss AS is unable to deploy this jar file. I have also tested that my created jar file contains the same files. When I create a jar file from the command using jar -cvf command, Jboss is able to deploy. I am sending the code , please review it and let me know the problem. I badly require your help. I am unable to proceeed in this regard. Please help me.
package com.rrs.corona.solutionsacceleratorstudio.solutionadapter;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.util.jar.JarEntry;
import java.util.jar.JarOutputStream;
import java.util.jar.Manifest;
import com.rrs.corona.solutionsacceleratorstudio.SASConstants;
* @author Piku Mishra
public class JarCreation
* File object
File file;
* JarOutputStream object to create a jar file
JarOutputStream jarOutput ;
* File of the generated jar file
String jarFileName = "rrs.jar";
*To create a Manifest.mf file
Manifest manifest = null;
//Attributes atr = null;
* Default Constructor to specify the path and
* name of the jar file
* @param destnPath of type String denoting the path of the generated jar file
public JarCreation(String destnPath)
{//This constructor initializes the destination path and file name of the jar file
try
manifest = new Manifest();
jarOutput = new JarOutputStream(new FileOutputStream(destnPath+"/"+jarFileName),manifest);
catch(Exception e)
e.printStackTrace();
public JarCreation()
* This method is used to obtain the list of files present in a
* directory
* @param path of type String specifying the path of directory containing the files
* @return the list of files from a particular directory
public File[] getFiles(String path)
{//This method is used to obtain the list of files in a directory
try
file = new File(path);
catch(Exception e)
e.printStackTrace();
return file.listFiles();
* This method is used to create a jar file from a directory
* @param path of type String specifying the directory to make jar
public void createJar(String path)
{//This method is used to create a jar file from
// a directory. If the directory contains several nested directory
//it will work.
try
byte[] buff = new byte[2048];
File[] fileList = getFiles(path);
for(int i=0;i<fileList.length;i++)
if(fileList.isDirectory())
createJar(fileList[i].getAbsolutePath());//Recusive method to get the files
else
FileInputStream fin = new FileInputStream(fileList[i]);
String temp = fileList[i].getAbsolutePath();
String subTemp = temp.substring(temp.indexOf("bin")+4,temp.length());
// System.out.println( subTemp+":"+fin.getChannel().size());
jarOutput.putNextEntry(new JarEntry(subTemp));
int len ;
while((len=fin.read(buff))>0)
jarOutput.write(buff,0,len);
fin.close();
catch( Exception e )
e.printStackTrace();
* Method used to close the object for JarOutputStream
public void close()
{//This method is used to close the
//JarOutputStream
try
jarOutput.flush();
jarOutput.close();
catch(Exception e)
e.printStackTrace();
public static void main( String[] args )
JarCreation jarCreate = new JarCreation("destnation path where jar file will be created /");
jarCreate.createJar("put your source directory");
jarCreate.close();Hi,
I have gone through your code and the problem is that when you create jar it takes a complete path address (which is called using getAbsolutePath ) (when you extract you see the path; C:\..\...\..\ )
You need to truncate this complete path and take only the path address where your files are stored and the problem must be solved. -
Netcfg problem with wep shared key
hello guys,
I would like to connect to a wireless device with netcfg. The device has a WEP encryption with shared key authentication. I'm able to connect using the gnome nm-applet, but with netcfg i keep getting the "Wireless association failed" error.
My config file for netcfg:
CONNECTION="wireless"
DESCRIPTION="A simple WEP encrypted wireless connection"
INTERFACE="wlan0"
SECURITY="wep"
ESSID="[essid]"
KEY="s:[password]"
IP="dhcp"
May the problem lie in the shared key authentication? I tried
IWCONFIG="enc restricted"
but it still doesn't work. I have an intel 3945 wireless card.
Any help is appreciated,
thanks.what puzzles me is that
1) i'm able to connect to the same device if I set the open authentication,
2) I'm able to connect if I set the WPA protection, and
3) I'm even able to connect (with WEP and shared key authentication) using gnome nm-applet.
The only problem I have is with netcfg and iwconfig, so i'm asking if iwconfig has a specific problem with shared authentication and if there is a way to handle it. -
Problem with the volume keys on my keyboard.
Hey everybody,
I have a problem with the volume keys on my keyboard. This started a couple days ago and I can't seem to figure out how to fix it. When I press the volume up or down buttons, the graphic appears on the screen as it normally would, but has no effect on the volume of the sound coming out of my speakers. Therefore, the only way to change the volume of music or whatever I am listening to is to use the volume control within the program/website itself (itunes, youtube, etc.) Even changing the volume on the volume icon at the menu bar on top of the screen does nothing. If anyone has an idea of how to go about solving this issue, I would greatly appreciate it. Thanks!First look into the Preference > Sound > Outpur whether internal Speakers are choosen.
The only Preference to delete I can discover is com.apple.systempreferences.plist in your home Library folder. You can try to move it out to the desktop for example, not to loose all your settings. Restart and see whether the problem still persists. If you don't know how to do this here some Terminal (Applications > Utilities) commands. Enter them by copy and paste followed by <enter>
mv ~/Library/Preferences/com.apple.systempreferences.plist ~/Desktop/
restart
to get it back:
mv ~/Desktop/com.apple.systempreferences.plist ~/Library/Preferences/
confirm with "y" if you are asked to replace this file.
marek -
When I first tried itunes with my new hard drive there was the problem with the registry keys but something also flagged up about needing a signed driver. Is this anything to do with why Itunes and my computer no longer recognises when my ipod is linked up? Whatever i try under 'devices' my ipod is never available to sync up. If anyone can help I would be most grateful.
Thanks for your reply. Unfortunately this has not worked. I didn't have quicktime to begin with so I don't know if that makes a difference? After following the instructions, I get the "registry keys missing" problem appear again (which I've subsequently fixed again) and then when I connected the ipod I got the following message - 'Device driver software was not successfully installed'.
I've tried windows update but this doesn't do anything as '...the service is not running'.
Any suggestions? -
Problem with Non-cumulative key figure.
Hi all,
I am facing the problem with the Non-cumulative Key Figure (Quantity). I have created and loaded data to the non-cumulative InfoCube. <b>This cube is defined by me to test the non-cumulative key figure.</b>
<b>In BEx query the non-cumulative key figure and cumulative key figure (Value change) both display same values, i.e. non-cumulative key figure contains the same values which we have loaded for cumulative value change. Non-cumulative key figure is not calculated based on associated cumulative key figure.</b>
I have done the following while defining the non-cumulative InfoCube:
1. Created a non-cumulative key figure which is associated with a cumulative key figure (value change).
2. Loaded data to non-cumulative InfoCube from flat file.
3. Compressed data in non-cumulative InfoCube after the load.
Note:
1. Validity area is determined by the system based on the minimum and maximum date in data.
2. Validity determining characteristic, 0CALDAY is the default characteristic selected by the system.
Is there any other settings to be done?
Please help me in resolving this issue.
Thanks and regards
Pruthvi RBeing a non-cumulative KF, total stock is automatically takes care of that.
Try putting all the restrictions which you have included for total receipts and total issues, for eg, restrict Total Stock with the movement types used in Receipts as well as Issues.
Check and revert.
Regards
Gajendra -
Hi All,
I have a table with the same data repeating 2 times. I mean the rows are depating twice. so now I am creating primary key to the table. It is throwing me an error saying primary key voilation. I will provide the clear scenario.
create table Employee(
ID VARCHAR2(4 BYTE) NOT NULL,
First_Name VARCHAR2(10 BYTE),
Last_Name VARCHAR2(10 BYTE),
Start_Date DATE,
End_Date DATE,
Salary Number(8,2),
City VARCHAR2(10 BYTE),
Description VARCHAR2(15 BYTE)
insert into employee values ('01','Jason', 'Martin', to_date('19960725','YYYYMMDD'), to_date('20060725','YYYYMMDD'), 1234.56, 'Toronto', 'Programmer');
insert into employee values ('02','Alison', 'Mathews', to_date('19760321','YYYYMMDD'), to_date('19860221','YYYYMMDD'), 6661.78, 'Vancouver','Tester');
insert into employee values ('03','James', 'Smith', to_date('19781212','YYYYMMDD'), to_date('19900315','YYYYMMDD'), 6544.78, 'Vancouver','Tester');
insert into employee values ('04','Celia', 'Rice', to_date('19821024','YYYYMMDD'), to_date('19990421','YYYYMMDD'), 2344.78, 'Vancouver','Manager');
insert into employee values ('05','Robert', 'Black', to_date('19840115','YYYYMMDD'), to_date('19980808','YYYYMMDD'), 2334.78, 'Vancouver','Tester');
insert into employee values ('07','David', 'Larry', to_date('19901231','YYYYMMDD'), to_date('19980212','YYYYMMDD'), 7897.78,'New York', 'Manager');
insert into employee values ('06','Linda', 'Green', to_date('19870730','YYYYMMDD'), to_date('19960104','YYYYMMDD'), 4322.78,'New York', 'Tester');
insert into employee values ('08','James', 'Cat', to_date('19960917','YYYYMMDD'), to_date('20020415','YYYYMMDD'), 1232.78,'Vancouver', 'Tester')
insert into employee values ('07','David', 'Larry', to_date('19901231','YYYYMMDD'), to_date('19980212','YYYYMMDD'), 7897.78,'New York', 'Manager');
insert into employee values ('06','Linda', 'Green', to_date('19870730','YYYYMMDD'), to_date('19960104','YYYYMMDD'), 4322.78,'New York', 'Tester');
Now the table is with 10 columns
ID FIRST_NAME LAST_NAME START_DAT END_DATE SALARY CITY DESCRIPTION
01 Jason Martin 25-JUL-96 25-JUL-06 1234.56 Toronto Programmer
02 Alison Mathews 21-MAR-76 21-FEB-86 6661.78 Vancouver Tester
03 James Smith 12-DEC-78 15-MAR-90 6544.78 Vancouver Tester
04 Celia Rice 24-OCT-82 21-APR-99 2344.78 Vancouver Manager
05 Robert Black 15-JAN-84 08-AUG-98 2334.78 Vancouver Tester
06 Linda Green 30-JUL-87 04-JAN-96 4322.78 New York Tester
07 David Larry 31-DEC-90 12-FEB-98 7897.78 New York Manager
08 James Cat 17-SEP-96 15-APR-02 1232.78 Vancouver ester
Creating Primary key to the table
"ALTER TABLE employee PRIMARY KEY ( ID, First_Name, Last_Name, Start_Date, End_Date,
Salary, City, Description );"
I am getting primary key voilation error
IS THERE ANY WAY TO CREATE PRIMARY KEY ON THE TABLE WITH OUT DELETING THE DATA?
iS IT POSSIBLE CREATING PRIMARY KEY BY USING 'GROUP BY' FUNCTION OR ANY OTHER FUNCTIONS?
Edited by: user11872870 on Sep 23, 2010 5:41 PMuser11872870 wrote:
Actually there is a small mistake in the question. The table is having the data as
ID FIRST_NAME LAST_NAME START_DAT END_DATE SALARY CITY DESCRIPTION
01 Jason Martin 25-JUL-96 25-JUL-06 1234.56 Toronto Programmer
02 Alison Mathews 21-MAR-76 21-FEB-86 6661.78 Vancouver Tester
03 James Smith 12-DEC-78 15-MAR-90 6544.78 Vancouver Tester
04 Celia Rice 24-OCT-82 21-APR-99 2344.78 Vancouver Manager
05 Robert Black 15-JAN-84 08-AUG-98 2334.78 Vancouver Tester
06 Linda Green 30-JUL-87 04-JAN-96 4322.78 New York Tester
07 David Larry 31-DEC-90 12-FEB-98 7897.78 New York Manager
08 James Cat 17-SEP-96 15-APR-02 1232.78 Vancouver ester
05 Robert Black 15-JAN-84 08-AUG-98 2334.78 Vancouver "NULL"
06 Linda Green 30-JUL-87 04-JAN-96 4322.78 New York "NULL"
There is a null in the duplicate data.....
As there is NULL in the data It is not allowing me to add the primary key to the table.....
I am just looking if there is any other way to create primary key with the same data....the reason for the null not allowing you to have unique records is because null means "unknown". I could go into this in more depth but....
...again - we need to ask, why do you have linda green and robert black in there twice.
if you really do need those two extra rows, then create another column with a unique ID using a sequence and make that the primary key. a primary key uniquely identifies a row. for this data I don't see any reason whatsoever to create a composite key like you are attempting.
by trying to make the entire row a primary key it is clear your understanding is severely lacking.
Maybe you are looking for
-
I have a different username on my icloud account on my iphone, how can I change it to my apple ID and log in? It was from when I initially set up the phone but needs updating but doesn't seem possible.
-
I lost a complete folder in iphoto. When I try to recover iPhoto from a previous date in time machine I only get back what is already current on my iMac. What am I doing wrong and what do I have to do to get a previous iPhoto version (date) recovere
-
I am on a MAC OSX 10.9.5, and using LR 5.7. I have lost the "Develop" Basic Panel (white balance & color saturation). Every thing else seems to be in place. How do I get it back?
-
Exchange 2013 management shell error
The problem am facing is that when I opened the Exchange management shell on my Exchange 2013 server locally it would fail to connect.The following error is receiving with Administrator account.I add another account in Organization Management Permi
-
TS1468 Why don't you use the album data in iTunes to recreate the album view?
that would keep all the songs on an album together