Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In this assignment, you will write a java program which takes any of the following commands as command line argument (not as input), and executes

In this assignment, you will write a java program which takes any of the following commands as command line argument (not as input), and executes them using JDBC: 1.) insert into relationname value1 value2 value3 ... Inserts a tuple into the specified relation with the specified values; test it with input containing single quotes (enclose those in double quotes so linux doesn't interpret the quotes) you can assume that all values are strings for simplicity 2.) select from relationnam Prints all tuples from the specified relation. 3.) select from relationname where "condition Executes a query with the specified condition. Note the use of double quotes so that the condition comes as a single command line parameter. 4.) select from relationname1 relationname Displays result of natural join of the two relations. Starter code is import java.sql.*; import java.io.*; public class jdb { public static void main(String[] args) throws Exception { final String DB_URL = "jdbc:postgresql://localhost/coastal"; Console input = System.console(); String password = new String(input.readPassword("[%s]", "Password:")); try { Connection conn = DriverManager.getConnection(DB_URL,"postgres",password); Statement stmt = conn.createStatement(); String query = "Select * from student"; stmt.executeUpdate(query); conn.close(); } catch(Exception e) { System.out.println("Error: " + e.getMessage()); } } }

PLEASE FINISH IT FOR ME!!!!

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Students also viewed these Databases questions