通过jdbc将表插入Oracle
我从未使用过 JDBC 或 Oracle 做过任何事情,但我已经通过这种方式连接到我的 jdbc:
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);
现在我需要使用哪些类将表插入数据库?任何帮助将不胜感激。 TIA
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
当您编写
将表插入数据库
时,您的意思是1) 在数据库中创建新表,还是
2) 在现有数据库表中添加新行?
无论哪种情况,请阅读@Marcelo Hernández Ris 发布的教程 然后遵循 JDBC 的好示例http://www.java2s.com/ 上的 Sql92 语法。
When you wrote
insert tables into the database
, did you mean1) 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/.
您需要PreparedStatement类: http://download.oracle .com/javase/6/docs/api/java/sql/PreparedStatement.html
以及 Java 教程:http://download.oracle.com/javase/tutorial/jdbc/basics/prepared.html
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