In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
Package org.sin.common.dao;import java.sql.CallableStatement;import java.sql.Connection;import java.sql.DriverManager;import java.sql.PreparedStatement;import java.sql.ResultSet;import java.sql.SQLException;import java.sql.Statement;import oracle.jdbc.OracleTypes;import org.sin.domain.User;public class JDBCDao {private static boolean mysql = false; private Connection conn Static {try {if (mysql) {Class.forName ("com.mysql.jdbc.Driver");} else {Class.forName ("oracle.jdbc.driver.OracleDriver") }} catch (ClassNotFoundException e) {e.printStackTrace ();}} private JDBCDao () {String url, user, password If (mysql) {url = "jdbc:mysql://127.0.0.1:3306/cl"; user = "root"; password = "";} else {url = "jdbc:oracle:thin:@localhost:1521:orcl" User = "andy"; password = "root";} try {conn = DriverManager.getConnection (url, user, password); System.out.println (conn.getAutoCommit ()) } catch (SQLException e) {e.printStackTrace ();}} private User SaveUser (User user) {String sql = "insert into t_User (id,username,password) values (user_id.nextval,?,?)"; Long id =-1L Try {conn.setAutoCommit (false); PreparedStatement ps = conn.prepareStatement (sql, Statement.RETURN_GENERATED_KEYS); int I = 0; for (I = 0; I
< 10000; i++) { ps.setString(1, user.getUsername() + "-" + i); ps.setString(2, user.getPassword() + "-" + i); ps.executeUpdate(); ResultSet rs = ps.getGeneratedKeys(); while (rs.next()) { id = rs.getLong(1); System.out.println(">> "+ id);}} conn.commit ();} catch (SQLException e) {e.printStackTrace ();} user.setId (id); return user } private User SaveUser2 (User user) {String sql = "BEGIN insert into t_user (id,username,password) values (user_id.nextval,?,?) Returning id into?; END; "; Long id =-1L; try {conn.setAutoCommit (false); CallableStatement cs = conn.prepareCall (sql); for
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.