Openshift Tomcat Mysql Javascript连接字符串

时间:2015-11-03 19:27:46

标签: java mysql string tomcat openshift

这是注册到网站的jsp的一部分,它将用户在另一个html中插入的数据放入一个mysql数据库......一切都在本地工作正常,但是当我上传网站时对于Openshift,它给String matot和cittatot一个错误:方法join(String,String [])未定义类型String

我也不太确定连接字符串是否正确lol

有人能温柔地帮助我吗?



<%@ page import ="java.sql.*" %>

<%

	 
	 
    String pass = request.getParameter("pass");
    String email = request.getParameter("email");
	String surname = request.getParameter("surname");
	String[] citta = request.getParameterValues("citta");
    String name = request.getParameter("name");
	String titolo = request.getParameter("titolo");
	String numero = request.getParameter("numero");
	String prezzo = request.getParameter("prezzo");
	String info = request.getParameter("info");
	String[] materia = request.getParameterValues("materia");
    
String matot = String.join(",",materia);
	String cittatot = String.join(",",citta);
	
    Class.forName("com.mysql.jdbc.Driver");

    String host = System.getenv("OPENSHIFT_MYSQL_DB_HOST");
String port = System.getenv("OPENSHIFT_MYSQL_DB_PORT");
String username = System.getenv("OPENSHIFT_MYSQL_DB_USERNAME");
String password = System.getenv("OPENSHIFT_MYSQL_DB_PASSWORD");

String url = String.format(":mysql://%s:%s/easylesson", host, port);
Connection con = DriverManager.getConnection(url, username, password);
    Statement st = con.createStatement();
    //ResultSet rs;
	 	
    int var = st.executeUpdate(" insert into iscritti(email,pass,datareg,titolo,numero,prezzo,info,cittatot,matot,name,surname) values ('" + email + "','" + pass + "', CURDATE(),'" + titolo + "','" +  numero+ "','" +  prezzo+ "','" +  info+ "','" +  cittatot+ "','" + matot + "','" + name + "','" +  surname+ "')");
&#13;
&#13;
&#13;

1 个答案:

答案 0 :(得分:0)

OpenShift上的Tomcat包含一个可用于此情况的预定义数据源。请尝试阅读以下示例信息:https://developers.openshift.com/en/tomcat-ds.html,了解如何使用它。