Create table and copy sample data into the database
1. Click the pgAdmin item in PostgreSQL menu entry in Startup->Programs bar of your Windows installation.
1. Click the pgAdmin item in PostgreSQL menu entry in Startup->Programs bar of your Windows installation.
2. A pgAdmin window will open.
3.
You will see a tree in the "Object Browser" window on the left half of
pgAdmin window labelled "Server1". A node named PostgreSQL9.3 will
appear below the Server1.
4. Double click the PostgreSQL9.X node and you will see a password prompt. Provide the database password you set at the time of your PostgresSQL installation.
4. Double click the PostgreSQL9.X node and you will see a password prompt. Provide the database password you set at the time of your PostgresSQL installation.
5. Double click the "Databases" child of PostgresSQL9.4 node; you will see all database instances listed.
6. Select "jasperdb1"child node under "Databases". Now click "Plugins" menu and select "PSQL Consol" option.
7. A SQL Shell consol with your jasperdb1 root will open. Copy following SQL commands into the consol.
CREATE TABLE "CustomerInvoices" (
"InvoiceID" integer NOT NULL,
"CustomerName" varchar(80) NOT NULL,
"ProductName" varchar(80) NOT NULL,
"InvoiceValue" real NOT NULL,
"InvoicePeriod" varchar(20) NOT NULL
CONSTRAINT CustomerInvoices_pkey PRIMARY KEY ("InvoiceID")
);
INSERT INTO "CustomerInvoices" VALUES (1001, ’iTwine Technologies’, ’Tech Material’ 5020.25, ’Mar14’);
INSERT INTO "CustomerInvoices" VALUES (1002, ‘iTwine Technologies’, ’Offset Paper’, 3000.50, ‘Apr14’);
INSERT INTO "CustomerInvoices" VALUES (1003, ‘iTwine Technologies’, ’Offset Paper’, 4150.05, ‘Jan14’);
INSERT INTO "CustomerInvoices" VALUES (1004, ’ iTwine Technologies’, ’Packing Material’, 2050.00, ‘Mar14’);
INSERT INTO "CustomerInvoices" VALUES (1005, ’ iTwine Technologies’, ’Packing Material’, 2050.00, ‘Jun14’);
INSERT INTO "CustomerInvoices" VALUES (1006, ’Revan’, ’JapserReports’, 50.00, ‘Jan15’);
8. Now press F5 to refresh your pgAdmin window.
The CustomerInvoices table will be listed under the jasperdb1->Schemas->public->Tables->CustomerInvoices.
One Important Note
While Coping SQL commands into the consol (SQL shell), use a simple text editor like Notepad to copy the commands. Avoid using WordPad or MsWord to copy the commands. Otherwise inverted-commas (“” and ‘’) can cause a syntax error.
When I was executing these recipes, I always used Notepad and the inverted comma problem never occurred. If you cannot use a simple editor like Notepad, you may follow the procedure described below, which although is a bit teasing but is a workaround to this problem.
If you face this problem then:
1. Copy one command at a time from the text file
2. While pasting the command into the Consol (SQL shell), edit the inverted comas manually after pasting there (i.e.by deleting the copied commas and then typing these commas using your keyboard manually)
Hopefully this will solve the problem.
"InvoiceID" integer NOT NULL,
"CustomerName" varchar(80) NOT NULL,
"ProductName" varchar(80) NOT NULL,
"InvoiceValue" real NOT NULL,
"InvoicePeriod" varchar(20) NOT NULL
CONSTRAINT CustomerInvoices_pkey PRIMARY KEY ("InvoiceID")
);
INSERT INTO "CustomerInvoices" VALUES (1001, ’iTwine Technologies’, ’Tech Material’ 5020.25, ’Mar14’);
INSERT INTO "CustomerInvoices" VALUES (1002, ‘iTwine Technologies’, ’Offset Paper’, 3000.50, ‘Apr14’);
INSERT INTO "CustomerInvoices" VALUES (1003, ‘iTwine Technologies’, ’Offset Paper’, 4150.05, ‘Jan14’);
INSERT INTO "CustomerInvoices" VALUES (1004, ’ iTwine Technologies’, ’Packing Material’, 2050.00, ‘Mar14’);
INSERT INTO "CustomerInvoices" VALUES (1005, ’ iTwine Technologies’, ’Packing Material’, 2050.00, ‘Jun14’);
INSERT INTO "CustomerInvoices" VALUES (1006, ’Revan’, ’JapserReports’, 50.00, ‘Jan15’);
8. Now press F5 to refresh your pgAdmin window.
The CustomerInvoices table will be listed under the jasperdb1->Schemas->public->Tables->CustomerInvoices.
And all the sample data is also inserted.
9.
After inserting the required data, you will connect iReport to your
database hosted on PostgreSQL. If you are not sure how to connect
iReport to your x database, you can see the steps described in Post 7: iReport: Creating a report from relational data.
Note that you have to enter jasperdb1 as name of the database instance
in step 10 of the “Creating a report from relational data” recipe.
One Important Note
While Coping SQL commands into the consol (SQL shell), use a simple text editor like Notepad to copy the commands. Avoid using WordPad or MsWord to copy the commands. Otherwise inverted-commas (“” and ‘’) can cause a syntax error.
When I was executing these recipes, I always used Notepad and the inverted comma problem never occurred. If you cannot use a simple editor like Notepad, you may follow the procedure described below, which although is a bit teasing but is a workaround to this problem.
If you face this problem then:
1. Copy one command at a time from the text file
2. While pasting the command into the Consol (SQL shell), edit the inverted comas manually after pasting there (i.e.by deleting the copied commas and then typing these commas using your keyboard manually)
Hopefully this will solve the problem.
One Important Tip
If you want to verify whether PostgreSQL Server is running, type “services.msc” at command prompt. Windows services dialog will appear. Verify that PostgreSQL Server 9.3 service is started. If its status is started then it is OK.
If you want to verify whether PostgreSQL Server is running, type “services.msc” at command prompt. Windows services dialog will appear. Verify that PostgreSQL Server 9.3 service is started. If its status is started then it is OK.
Comments
Post a Comment