Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Insert tables into Oracle through jdbc

I've never done anything with JDBC or much with Oracle, but I've connected to my jdbc this way:

     String driverName = "oracle.jdbc.driver.OracleDriver";
         Class.forName(driverName);

         // Create a connection to the database
         String serverName = "xxx.xx.xx;
         String portNumber = "1521";
         String sid = "mysid";
         String url = "jdbc:oracle:thin:@" + serverName + ":" + portNumber  
                                               + ":" + sid;
         String username = "PGSWLOG";
         String password = "PGDEV";
         connection = DriverManager.getConnection(url, username, password);

Now what classes do i need to use to insert tables into the database? Any help would be appreciates. TIA

like image 265
auwall Avatar asked Nov 18 '25 22:11

auwall


2 Answers

When you wrote insert tables into the database, did you mean

1) Create a new table in DB, or

2) Add new row(s) into an existing DB table?

In either case, read the tutorials posted by @Marcelo Hernández Ris and then follow with the good examples for JDBC and Sql92 syntax on http://www.java2s.com/.

like image 145
mKorbel Avatar answered Nov 20 '25 11:11

mKorbel


You need the PreparedStatement class: http://download.oracle.com/javase/6/docs/api/java/sql/PreparedStatement.html

And from the Java Tutorials: http://download.oracle.com/javase/tutorial/jdbc/basics/prepared.html

like image 44
Marcelo Avatar answered Nov 20 '25 11:11

Marcelo



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!