Question
have to make an SQL Java Database.
webdaxlpid-12771371-dt-content-rid-89561 4 Delete a student S. Register a counse 7. Check student egstration 8 Uplond grades


prop table Registered; op table student; reate table Student address varchar (100), mafor char (10) eate table course code ch
mport java.io. public class JDBCORACLE eparam args the command line arguments public statie void main (Stringtl arga) throws
NC191 System.out printin(ID:+user +* pansvordpword) : rs.close at.close conn.close catch (Exception e) Systen.err printin(e
webdaxlpid-12771371-dt-content-rid-89561 4 Delete a student S. Register a counse 7. Check student egstration 8 Uplond grades 9.Check gale
prop table Registered; op table student; reate table Student address varchar (100), mafor char (10) eate table course code char (10) primary key title varchar C reate table Registered code char(a0). senester char (10), preign Key ssn) reférences student (ssa) foreign key (code) references prinary key (ssn,code.year,senester) tnsert into Student values (555550001, "Ton Harks" 100 11en st.. Spartarburg, Sc 29301 CIS Spartanburg, sC 2930 mert into course valuessz0 computer science 1"1 13% tnme course values C350 Analysis of algorithas 50005, MATH C350" 203 spr ing SAMSUNG
mport java.io. public class JDBCORACLE eparam args the command line arguments public statie void main (Stringtl arga) throws SQLException, IOException CEY Class.forName ("oracle.jdba.driver.OracleDrivez"): I/Load the Oracle JDBC driver catch (ClasaNotFoundExcersion e) System.out.printin("Could not load the driver") try //eonneet to oracie and validate the user and pasad String Oracleuser,Oraclepass: Oracleaser readEntry("Orscle username: oraclepass readEntry ("Oracle Passvord: " String url-jdbe:oracleithin:8tedoral.uscupstate. edu:1521xe a Connection conn -DriverManager.getConnection (url,Oracieuser, Oraciepasa) /connect oracle Statement st-conn.createStatesent st.executeopdatedelete from login") at executelpdate ("insert into Jogin values(ue 123156) ): at.executeopdate(insert imnto login valuesuner?, *3234569 ResultSet r-gt.executeQuezy( select rom login") Sering er-* String password while (ES DexE 0) s.getstring (2)2 password-zs.getsering(2) ystem.out-peintin"D passvord s t close h catch (Exeeptione Syacem.err-printin(e.getMeasage 0 SAMSUNG
NC191 System.out printin("ID:"+user +* pansvordpword) : rs.close at.close conn.close catch (Exception e) Systen.err printin(e.getHessage )) Urility funetion to read a line from standard inpat static String readEntry (String prompt SeringBuffer batter new Stringbuttero System.out-print (prompt) System.out.Fluah int -System.in.read) butter.append ((char)e) System.in.read) return buffer.toStringo.trinD cateh (IOException e SAMSUNG
0 0
Add a comment Improve this question Transcribed image text
Answer #1

Note: You must download Orcale JDBC Driver to Run this program (Look like ojdbc7.jar) and put that jar file in class path

download jar file here https://www.oracle.com/technetwork/database/application-development/jdbc/downloads/index.html

(choose proper driver based on your oracle database).

create file name DatabaseConnection.java and insert below code

  1. import java.sql.*;
  2. class DatabaseConnection{
  3. public static void main(String args[]){
  4. try{
  5. Class.forName("oracle.jdbc.driver.OracleDriver");
  6. //Please enter your database username and password in below line(Don't confuse with login user and password)
  7. Connection con=DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:xe","username","password");
  8. String user="bob";
  9. String pass="don';
  10. boolean result = login(con, user, pass);
  11. if(result){
  12. System.out.println("Login success");
  13. }else{
  14. System.out.println("Login Fail");
  15. }
  16. }catch(Exception e){
  17. e.printStackTrace();
  18. }
  19. finally{
  20. rs.close();
  21. stmt.close();
  22. con.close();
  23. }
  24. }
  25. //Login function return if login success true else false
  26. public static boolean login( Connection con, String username, String password){
  27. try{
  28. Statement stmt=con.createStatement();  
  29. ResultSet rs=stmt.executeQuery("select * from tableName where username='"+username+"' and password='"+password+"'");  
  30. while(rs.next()){
  31. return true;
  32. }
  33. }
  34. catch(Exception e){
  35. e.printStackTrace();
  36. }
  37. finally{
  38. rs.close();
  39. stmt.close();
  40. con.close();
  41. }
  42. return false;
  43. }
  44. }

Your First Image is not clearly visible. the above code will work for all operations of database like insert, delete, update etc

Add a comment
Know the answer?
Add Answer to:
Webdaxlpid-12771371-dt-content-rid-89561 4 Delete a student S. Register a counse 7. Check student...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • 9 We want to find out the courses that each student is not enrolled in. Give a listing of the course descriptions, and the students (lname) who are not taking that specific course (Use a cartesi...

    9 We want to find out the courses that each student is not enrolled in. Give a listing of the course descriptions, and the students (lname) who are not taking that specific course (Use a cartesian product and union it with a minus) drop table student_class; drop table student; drop table class; create table student ( ssn char(11) not null, lname varchar(40) not null, fname varchar(20) not null, phone char(12), address varchar(40), city varchar(20), state char(2), zip char(5), dob date,...

  • Suppose a student is taking IS 620 section 1 and HCC 629 section 1 for spring...

    Suppose a student is taking IS 620 section 1 and HCC 629 section 1 for spring 2019. Use an explicit cursor to print out the titles and prices of textbooks for these two courses. Sample code to create the tables: drop table textbook_schedule cascade constraints; drop table textbook_author cascade constraints; drop table schedule cascade constraints; drop table course cascade constraints; drop table textbook cascade constraints; drop table author cascade constraints; drop table teacher cascade constraints; drop table program cascade constraints;...

  • MYSQL Questions: 1.For every author, display the number of books written by that author that is...

    MYSQL Questions: 1.For every author, display the number of books written by that author that is carried by Henry Books. Display the author number as ‘Author Number’, author name concatenated (first last) as ‘Author Name’, and the total number of books written by the author as ‘Number of Titles by Author’. List in descending order by author number. Limit the output to 10 rows. Insert your snip of the query and resultset together here. 2.Using a function, what are the...

  • MYSQL: Question: 1.Using a function, what are the lowest price books found in paperback? Only return...

    MYSQL: Question: 1.Using a function, what are the lowest price books found in paperback? Only return the lowest price books. Display the book code as ‘Book Code’, the book title as ‘Title’, author name concatenated (first last) as ‘Author Name’ and price as ‘Price’. Insert your snip of the query and resultset together here. 2. Display the number of publishers by city.   Display the city as ‘City’ and the number of publishers in that city as ‘Number of Publishers’. Insert...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
Active Questions
ADVERTISEMENT