当前位置:首页 » 编程语言 » js解析sql
扩展阅读
webinf下怎么引入js 2023-08-31 21:54:13
堡垒机怎么打开web 2023-08-31 21:54:11

js解析sql

发布时间: 2022-07-05 18:48:42

① js中的sql语句问题,在线等,求高手!

js是在浏览器端执行的,而数据库是在服务器的,所以js是不能操作数据库的。
至于比较时间的话,第二个时间 t2 应该是时间戳。 第一个时间你可以网络以下 js日期转换时间戳的函数。其实很简单,换算成秒就好了。
转换完以后就直接比较大小就OK

② 如何使用js调用sql数据库文件

JS怎么连接数据,老兄你太有才了,JS
只能异步请求,后台处理。

③ 关于JS获取MSSQL2005数据库数据问题

如果是要异步获取
就要按楼上所说,用iframe或ajax
如果说只在页面显示的时候给出提示消息
只需要把这部分信息绑定到页面上就可以了
你可以生成一段JS然后绑定到页面上
如string js="alert('aaa');"//全局变量
页面上 <script type='text/javascript'><%=js%></script>
或者用<input type="hidden"/>来保存你的数据,再用JS读取
等等

④ javascript如何获得后台sql语句查询的结果,

有很多方法的,像你已经这样用setAttribute了,那么在客户端你就用getAttribute("cList")就能拿到cList了,不过你要用jsp的尖括号。另外最常用的是用struts标签,在action总对cList用一个set get方法,然后用<s:property value="cList"/>就可以了

个人意见,仅供参考

⑤ JS读取MYSQL数据表或PHP读取后写入JS

js是脚本语言,你用js脚本语言去读数据库,那你的数据库的所有信息不都暴露出来了?最好的方法就是还是通过php去读取,读取到的是xml数据,然后再用js去解析这些数据,最后动态的插入到DOM中!其实也就是AJAX。

⑥ 如何用javascript代码取得sql2005内容

应该用AJAX
ajax判断用户名是否已经存在
1. register.jsp
<%@ page language="java" import="java.util.*" pageEncoding="GBK"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme() + "://"
+ request.getServerName() + ":" + request.getServerPort()
+ path + "/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">
<title>用户注册</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->
</head>
<script type="text/javascript">
function checkUserName(userName)
{
alert(userName);
var xmlhttp;
------------------------------------------------------
try{
xmlhttp= new ActiveXObject('Msxml2.XMLHTTP');
}catch(e){
try{
xmlhttp= new ActiveXObject('Microsoft.XMLHTTP');
}catch(e){
try{
xmlhttp= new XMLHttpRequest();
}catch(e){}
}
}
--------------------------------------------------------
//创建请求,并使用escape对userName编码,以避免乱码
xmlhttp.open("get","userServlet?userName="+escape(userName));
xmlhttp.onreadystatechange=function()
{
if(xmlhttp.readystate==4){
if(xmlhttp.status==200)
{
//根据responseText判断用户名是否存在
if(xmlhttp.responseText=="1") alert('对不起,用户名已经存在!');
else
alert("恭喜,该用户未被注册!");
}
else
{
alert("网络链接失败!");
}

}
}
xmlhttp.send(null);
}
</script>
<body>
注册用户,利用Ajax检查用户名是否已经存在.
<form name="form1" action="userServlet">
用户名:<input name="userName">
<input type="button" value="检测用户名" onclick="checkUserName(form1.userName.value)"><p>
密码:<input name="password"><p>
<input type="submit">
</form>
<hr>
</body>
</html>

2. web.xml

<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.4"
xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
<servlet>
<description>user</description>
<display-name>user of ajax</display-name>
<servlet-name>userServlet</servlet-name>
<servlet-class>cn.sun.ajaxdemo.controller.userServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>userServlet</servlet-name>
<url-pattern>/userServlet</url-pattern>
</servlet-mapping>
</web-app>

3. userServlet.java
package cn.sun.ajaxdemo.controller;
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public class userServlet extends HttpServlet {
public userServlet() {
super();
}
public void destroy() {
super.destroy(); // Just puts "destroy" string in log
// Put your code here
}
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
this.doPost(request, response);
}
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
PrintWriter out = response.getWriter();
System.out.println(request.getParameter("userName"));
//此处可以访问数据库
String userName = request.getParameter("userName");
if (userName.equals("admin"))
out.print("1");
else
out.print("0");
}
public void init() throws ServletException {
// Put your code here
}
}

⑦ js怎么连接SQl查询 sql查询语句要在其他文件夹中

js是不能直接连接SQL查询的,所以你必须向后台发送请求,然后将请求处理结果返回前台,或者用Ajax异步请求,发送请求,后台验证后返回一个值用于保存判断结果

⑧ js如何正确连接sql数据库

如果你想用在html页面上,那是会报错的。
如果你保存成一个js文件,有鼠标双击执行这个js文件,这个是可以的,
除非你没有安装
ADODB
驱动.