假设登陆Oracle的数据库,连接方式
String driver = "oracle.jdbc.OracleDriver";
Connection cn = null;
Class.forName(driver);
String url = "jdbc:oracle:thin:@localhost:1521:ORACLE";
String user = "system";
String pwd = "密码";
cn = DriverManager.getConnection(url,user,pwd);
Statement st = cn.createStatement();
String sql = "Insert into loginfo (id,username,user,type) values( "id="+你的id+"username="+user+",password="+pwd+",type="+你的type);
st.executeUpdate(sql);
st.closed;
cn.closed;
Mysql Database
Class.forName("com.mysql.jdbc.Driver");
conn = DriverManager.getConnection(
"jdbc:mysql://localhost:3306/数据库名称",
"账户","密码");
localhost你的ip地址
3306 mysql的数据库端口号这个不用改
追问我是一个新手菜鸟,大神可以说的详细一点吗?