在国产处理器服务器上搭建mysql(MariaDB)+jsp(java)开发平台。(基于海之舟1.0A操作系统)

1.mysql设置
对于海之舟1.0A操作系统,mysql、java、tomcat已预装,在/etc/rc.local中设定开机启动即可。
su root
nano /etc/mysql/mariadb.conf.d/50-server.cnf
#bind-address = 127.0.0.1 //注释这行,关闭ip限制.
mysql -v //进入数据库

use mysql;
CREATE DATABASE db1;
SHOW DATABASES;
grant all on . to zs1@’%’ identified by ‘1234’;
show grants for zs@’%’;
use db1;
CREATE TABLE t1(bid int(20) not null auto_increment primary key, id int(100),xm varchar(20),zh varchar(100),uploadTime varchar(100));
SHOW TABLES;
DESCRIBE t2; //查看表t2的结构
insert into t1(id,xm,zh) values (20,“zhangs”,“myzh”);
2.jsp
su zs
cd /home/zs/apache-tomcat-8.5.35/webapps/ROOT
nano m1.jsp //已预置的范例代码
<%@ page contentType=“text/html;charset=UTF-8”%>
<%@ page import=“java.sql.*”%>

<% response.setContentType("text/html;charset=UTF-8"); request.setCharacterEncoding("UTF-8"); %> <% Class.forName("com.mysql.cj.jdbc.Driver").newInstance(); Connection conn=DriverManager.getConnection("jdbc:mysql://localhost:3306/db1", "zs1", "1234"); Statement stmt=conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE); String id=request.getParameter("id"); String sql="select * from t1 order by bid"; ResultSet rs=stmt.executeQuery(sql); out.print("
sql:"+sql); out.print("
bid-----id-----xm-----zh"); while(rs.next()) { out.print("
  "+rs.getInt(1)); out.print("    "+rs.getString(2)); out.print("    "+rs.getString(3)); out.print("    "+rs.getString(4)); } //c=Integer.parseInt(ss); rs.close(); stmt.close(); conn.close(); %> 在流览器中打开192.168.1.125:8080/m1.jsp即可 ![在这里插入图片描述](https://img-blog.csdnimg.cn/20191025103508626.jpg?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3d4aDU4NQ==,size_16,color_FFFFFF,t_70)

你可能感兴趣的:(在国产处理器服务器上搭建mysql(MariaDB)+jsp(java)开发平台。(基于海之舟1.0A操作系统))