php连接数据库出现问题

图片说明
图片说明
$conn = mysqli_connect($servername,$username,$password);
if ($conn) {
// $conn->query("SET NAMES 'UTF8'");
mysqli_select_db($conn,$dbname);

$search = "select check_num FROM check where check_num ='".$_POST["number"]."'";

  $result = mysqli_query($conn,$search);
  $datarow = mysqli_num_rows($result);
    $arr = array();
    if($datarow>0){
       //     $content = json_encode($_SESSION['username']);
       //  if($f  = file_put_contents($file, $content,FILE_APPEND)){// 这个函数支持版本(PHP 5)
       // //echo "写入成功。<br />";
      // }

      for($i = 0;$i < $datarow ; $i++){
        $search_arr = mysqli_fetch_assoc($result);
        $number = $search_arr['check_num'];
        $password = $sreach_arr['check_pass']; 
      }

       $arr['result'] = 1 ;
       $arr['data'] = $password;

    }else{
           $arr['result'] = 0;
           $arr['data'] = '验证码输入错误';
         }

    echo json_encode($arr);
}
 $conn->close();
 ?>
    三个问题
    1.   Warning: mysqli_num_rows() expects parameter 1 to be mysqli_result, boolean given in G:\Wamp\wamp\www\electricmobile\check.php on line 27
    2. Notice: Undefined index: number in G:\Wamp\wamp\www\electricmobile\check.php on line 24
    3. Warning: mysqli_num_rows() expects parameter 1 to be mysqli_result, boolean given in G:\Wamp\wamp\www\electricmobile\check.php on line
    这是什么情况 为什么我一用mysqli_num_rows 就出错

2个回答

你数据库链接错了,少了dbname
图片说明
$password = $sreach_arr['check_pass']; 这行变量名也写错了

qq_35318529
Destiny_Fc 回复qq_29335283: 我的dbname是加着的,我已经找到错误的根源了,一共是两个错误 1.数据库关键字check被我当成表名使用了。2.我需要数据库的两个数据,结果我只获取了check_num,没有获取check_pass
一年多之前 回复
qq_29335283
qq_29335283 回复qq_35318529: mysqli_num_rows() 函数返回结果集中行的数量。应该是你数据库连接不上,或者语句写错了,你可以把你语句运行下看看或把dbname加上看看
一年多之前 回复
qq_35318529
Destiny_Fc 我的数据库选择没错吧 你看我贴的图里面,我其他页面也这样写的,没有出错,我把search改回去了,但还是上面的错误
一年多之前 回复

$result = mysqli_query($search,$conn); sql语句放前面吧

qq_35318529
Destiny_Fc 不,sql语句放前面的是 mysql_吧
一年多之前 回复
Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
其他相关推荐
连接数据库出现问题
错误如下:rncom.microsoft.sqlserver.jdbc.SQLServerException: 通过端口 1433 连接到主机 localhost 的 TCP/IP 连接失败。错误:“Connection refused: connect。请验证连接属性。确保 SQL Server 的实例正在主机上运行,且在此端口接受 TCP/IP 连接,还要确保防火墙没有阻止到此端口的 TCP 连接。”。rn com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDriverError(SQLServerException.java:190)rn com.microsoft.sqlserver.jdbc.SQLServerException.ConvertConnectExceptionToSQLServerException(SQLServerException.java:241)rn com.microsoft.sqlserver.jdbc.SocketFinder.findSocket(IOBuffer.java:2243)rn com.microsoft.sqlserver.jdbc.TDSChannel.open(IOBuffer.java:491)rn com.microsoft.sqlserver.jdbc.SQLServerConnection.connectHelper(SQLServerConnection.java:1309)rn com.microsoft.sqlserver.jdbc.SQLServerConnection.login(SQLServerConnection.java:991)rn com.microsoft.sqlserver.jdbc.SQLServerConnection.connect(SQLServerConnection.java:827)rn com.microsoft.sqlserver.jdbc.SQLServerDriver.connect(SQLServerDriver.java:1012)rn java.sql.DriverManager.getConnection(DriverManager.java:582)rn java.sql.DriverManager.getConnection(DriverManager.java:185)rn org.apache.jsp.userlist_jsp._jspService(userlist_jsp.java:123)rn org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)rn javax.servlet.http.HttpServlet.service(HttpServlet.java:727)rn org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:432)rn org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390)rn org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)rn javax.servlet.http.HttpServlet.service(HttpServlet.java:727)rn代码如下:rnString sDBDriver = "com.microsoft.sqlserver.jdbc.SQLServerDriver";rnString sConnStr = "jdbc:sqlserver://localhost:1433;DatabaseName=ST";rnrnString userName = "tardis"; rnrnString userPwd = "1234"; rnrnConnection conn = null;rnResultSet rs = null;rnrntry rn Class.forName(sDBDriver);rn catch(java.lang.ClassNotFoundException e) rn rn System.err.println("faq(): " + e.getMessage());rn rnrnconn = DriverManager.getConnection(sConnStr,userName,userPwd);rnStatement stmt = conn.createStatement();rnrnrnString sql = "select * from student";rnrs = stmt.executeQuery(sql);rn搜索很多方案依然没有作用。rnrn
问:连接数据库的时候出现问题
SQL Server Does not exist or access deniedrn
连接数据库时出现问题,急!
我在连接数据库时出现问题,代码如下:rn<%rndim com,rsrnset com=server.createobject("adodb.connection") rnrs="DBQ="&server.mappath("database\qiye.mdb")&";rs=;DRIVER=Microsoft Access Driver (*.mdb);"rncom.open rsrnrnResponse.write "连接成功"rnrnrs.close rncom.closern%> rn但运行后出现问题:rnMicrosoft VBScript 运行时错误 错误 '800a01a8' rnrn缺少对象: 'DBQ=C:\myweb\databas' rnrn/外贸.asp, 行20 rnrn请教,这是为什么?难道使用ado连接数据库时还要设置?设置什么? rnrn
oledb连接数据库access出现问题????
protected void Page_Load(object sender, EventArgs e)rn rn int strID = Convert.ToInt32(Request["id"]);// QueryString["id"]);rn string strConn = "Provider=Microsoft.Jet.OLEDB.4.0;" + "Data Source=" + Server.MapPath("liuyan.mdb");rn OleDbConnection Conn = new OleDbConnection(strConn);rn Conn.Open();rn OleDbDataAdapter da = new OleDbDataAdapter("select * from liu where u-id="+strID, Conn);rn //OleDbDataAdapter da = new OleDbDataAdapter("select * from liu", Conn);rn DataSet ds = new DataSet();rnrn da.Fill(ds, "han");rn Repeater1.DataSource = ds.Tables["han"].DefaultView;rn Repeater1.DataBind();rn Conn.Close();rnrn rnrn搞了半天都没搞清楚。。。错误如下:rnrnrn至少一个参数没有被指定值。 rn说明: 执行当前 Web 请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。 rnrn异常详细信息: System.Data.OleDb.OleDbException: 至少一个参数没有被指定值。
java 连接数据库出现问题
连接数据库建表中出现如下报错,学生刚入门,求大神帮忙看一下原因nException in thread "main" java.lang.NullPointerExceptionn at com.mysql.jdbc.Statement.executeUpdate(Statement.java:1214)n at com.mysql.jdbc.Statement.executeUpdate(Statement.java:1205)n at Week4.One.main(One.java:29)n n n 代码如下nn```n package Week4;nimport java.sql.*;nimport java.sql.Connection;nimport java.sql.DriverManager;nimport java.sql.SQLException;nnnpublic class One n public static void main(String[] args) throws Exceptionn n Class.forName("com.mysql.jdbc.Driver");nn n String url = "jdbc:mysql://127.0.0.1:3306/hello"; n Connection conn = DriverManager.getConnection(url, "root", "");n Statement stat = conn.createStatement();nn n nnn stat.close();n conn.close();nn stat.executeUpdate("create table oe_class("n + "clid int not null,"n + "coid int not null,"n + "seeid int not null,"n + "uname int not null,"n + "sesid int not null,"n +"clweek int not null,"n +"primary key (clid);"n + ")");n n stat.executeUpdate("create table oe_course("n + "coid int not null,"n + "coname varchar(20) not null,"n n +"primary key (coid);"n + ")");nn```nnn
利用JDBC连接数据库出现问题
我在MyEclipse中通过JDBC来连接数据库2005版,出现了一些问题,请各位帮忙解决一下,谢谢!rn 我已经导入了jar包,且SQL Server 2005打了补丁rn 连接数据库代码如下:rn public class DbConnection rn public Connection getConnection()rn rn Connection con = null;rn try rn Class.forName("net.sourceforge.jtds.jdbc.Driver");rn con = DriverManager.getConnectionrn ("jdbc:jtds:sqlserver://localhost:1433/Student","sasa","sasa");rn con.close();rn catch (Exception e) rn e.printStackTrace();rn rn return con;rn rn public static void main(String[] args) rn System.out.println(new DbConnection().getConnection());rn rn rn 运行第一次错误提示如下: I/O Error: Unknown packet type 0x44rn 保存后再次运行错误提示如下:用户 'sasa' 登录失败。该用户与可信 SQL Server 连接无关联。rn 请各位帮忙解决,谢谢!rn
JBuilder连接数据库后出现问题!
没有办法在jdbtabel中修改数据 运行时错误提示 rndataset has no unique row identifiers rnfor querydatasets you need to disabel Metadataupdate.ROWD....... rn不知道大家是否遇到过类似的问题,有什么解决方法? rn谢谢! rn
求救:连接数据库时出现问题
在使用数据库时出现rnMicrosoft OLE DB Provider for Oracle 错误 '80004005' rnrn未找到 Oracle 客户端和网络组件。这些组件是由 Oracle 公司提供的,是 Oracle 8i 版 (或更高) 客户软件安装的一部分。 在安装这些组件之前,将无法使用此提供程序。rnrn我还需在服务器上装什么数据库驱动吗rn怎么办rn用ASP连接,以前用过,现在不好用了rn
hibernate连接数据库出现问题
[size=13px] Could not open connectionrn at org.hibernate.exception.internal.StandardSQLExceptionConverter.convert(StandardSQLExceptionConverter.java:54)rn at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:125)rn at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:110)rn at org.hibernate.engine.jdbc.internal.LogicalConnectionImpl.obtainConnection(LogicalConnectionImpl.java:304)rn at org.hibernate.engine.jdbc.internal.LogicalConnectionImpl.getConnection(LogicalConnectionImpl.java:169)rn at org.hibernate.engine.transaction.internal.jdbc.JdbcTransaction.doBegin(JdbcTransaction.java:67)rn at org.hibernate.engine.transaction.spi.AbstractTransactionImpl.begin(AbstractTransactionImpl.java:160)rn at org.hibernate.internal.SessionImpl.beginTransaction(SessionImpl.java:1396)rn at com.qfnu.Dao.impl.PersonDaoImpl.savePerson(PersonDaoImpl.java:21)rn at com.qfnu.service.impl.PersonServiceImpl.savePerson(PersonServiceImpl.java:13)rn at com.qfnu.action.PersonAction.savePerson(PersonAction.java:54)rn at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)rn at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)rn at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)rn at java.lang.reflect.Method.invoke(Method.java:597)rn at com.opensymphony.xwork2.DefaultActionInvocation.invokeAction(DefaultActionInvocation.java:450)rn at com.opensymphony.xwork2.DefaultActionInvocation.invokeActionOnly(DefaultActionInvocation.java:289)rn at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:252)rn at org.apache.struts2.interceptor.DeprecationInterceptor.intercept(DeprecationInterceptor.java:41)rn at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)rn at org.apache.struts2.interceptor.debugging.DebuggingInterceptor.intercept(DebuggingInterceptor.java:256)rn at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)rn at com.opensymphony.xwork2.interceptor.DefaultWorkflowInterceptor.doIntercept(DefaultWorkflowInterceptor.java:167)rn at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)rn at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)rn at com.opensymphony.xwork2.validator.ValidationInterceptor.doIntercept(ValidationInterceptor.java:265)rn at org.apache.struts2.interceptor.validation.AnnotationValidationInterceptor.doIntercept(AnnotationValidationInterceptor.java:68)rn at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)rn at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)rn at com.opensymphony.xwork2.interceptor.ConversionErrorInterceptor.intercept(ConversionErrorInterceptor.java:138)rn at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)rn at com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:254)rn at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)rn at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)rn at com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:254)rn at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)rn at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)rn at com.opensymphony.xwork2.interceptor.StaticParametersInterceptor.intercept(StaticParametersInterceptor.java:191)rn at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)rn at org.apache.struts2.interceptor.MultiselectInterceptor.intercept(MultiselectInterceptor.java:73)rn at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)rn at org.apache.struts2.interceptor.CheckboxInterceptor.intercept(CheckboxInterceptor.java:91)rn at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)rn at org.apache.struts2.interceptor.FileUploadInterceptor.intercept(FileUploadInterceptor.java:252)rn at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)rn at com.opensymphony.xwork2.interceptor.ModelDrivenInterceptor.intercept(ModelDrivenInterceptor.java:100)rn at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)rn at com.opensymphony.xwork2.interceptor.ScopedModelDrivenInterceptor.intercept(ScopedModelDrivenInterceptor.java:141)rn at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)rn at com.opensymphony.xwork2.interceptor.ChainingInterceptor.intercept(ChainingInterceptor.java:145)rn at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)rn at com.opensymphony.xwork2.interceptor.PrepareInterceptor.doIntercept(PrepareInterceptor.java:171)rn at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)rn at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)rn at com.opensymphony.xwork2.interceptor.I18nInterceptor.intercept(I18nInterceptor.java:139)rn at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)rn at org.apache.struts2.interceptor.ServletConfigInterceptor.intercept(ServletConfigInterceptor.java:164)rn at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)rn at com.opensymphony.xwork2.interceptor.AliasInterceptor.intercept(AliasInterceptor.java:193)rn at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)rn at com.opensymphony.xwork2.interceptor.ExceptionMappingInterceptor.intercept(ExceptionMappingInterceptor.java:189)rn at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)rn at org.apache.struts2.impl.StrutsActionProxy.execute(StrutsActionProxy.java:54)rn at org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:562)rn at org.apache.struts2.dispatcher.ng.ExecuteOperations.executeAction(ExecuteOperations.java:77)rn at org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.doFilter(StrutsPrepareAndExecuteFilter.java:99)rn at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)rn at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)rn at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230)rn at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)rn at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)rn at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:104)rn at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)rn at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:261)rn at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)rn at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:581)rn at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)rn at java.lang.Thread.run(Thread.java:619)rnCaused by: java.sql.SQLException: Io 异常: The Network Adapter could not establish the connectionrn at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:134)rnrnrn我的hibernate.cfg.xml文件如图所示:[img=https://img-bbs.csdn.net/upload/201410/21/1413902938_735433.jpg][/img]rnrnjar包文件如下:rn[img=https://img-bbs.csdn.net/upload/201410/21/1413902977_852644.jpg][/img]rnrnrnrn[/size]
VC连接数据库出现问题啦
最近在做个数据库系统,之前做好了一个只是连接一个数据库的VC 运行成功,没错误,功能齐全。当我连接三个数据库后,编译也没错误,但是!!!运行时竟然跳出这个东西![img=http://桌面/未命名][/img]rnrn[b]this application has requested the runtime to terminate it in an unusual way.please contact the application's support team for more information[/b]rn求高手指教 这是怎么回事?怎么解决???
使用sqlplus连接数据库出现问题
C:\>SET ORACLE_SID=ORACLE1rnrnC:\>sqlplus oracle/oraclernrnSQL*Plus: Release 10.2.0.1.0 - Production on 星期一 9月 28 14:44:12 2009rnrnCopyright (c) 1982, 2005, Oracle. All rights reserved.rnrnrn我在windows xp中安装了oracle数据库,在本地使用sqlplus连接数据库,在连接的过程中,光标就停留在上面的情况,不停的闪,没有继续向后面进行处理啊!不知道是什么原因,请高手给看一下,谢谢
silverlight连接数据库出现问题
rn 我是刚学silverlight,想搭建三层就像ASP.NET一样,可是我看书上说它必须建一个WCF服务rn 我按着书上的步骤添加了,可是到了在siverlight应用程序中引用WCF服务的时候,点确定就是引用出问题rn 说是什么找不到rn 给位要是知道这个问题麻烦给我说一下,我真的很急···rn 谢谢各位了··
JDBC连接数据库出现问题了
![![图片说明](https://img-ask.csdn.net/upload/201606/05/1465105527_776088.png)图片说明](https://img-ask.csdn.net/upload/201606/05/1465105520_701756.png)n这是在Structs下运行的
连接数据库出现问题,请指教~~~~~~~~~~~~~
org.apache.jasper.JasperException: [Microsoft][SQLServer 2000 Driver for JDBC][SQLServer]无法打开登录 'xuxin' 中请求的数据库。登录失败。rn什么原因挖????
程序发布连接数据库出现问题
小弟的一套系统即将完毕,在试着编译后,发现有问题。rn我用的是powerbuilder 6.5 +SQL Anywhere 5.0 rn现象是这样的:rn我第一次编译后,运行,发现不能连接数据库。rn经高人指点,我将SQL Anywhere 5.0的安装目录下的win32目录里的东西都拷贝到我的应用程序目录里。rn第二次编译后,发现连接数据库能连接了,登陆界面过去了,主界面也进入了,可是rn再往下,进入某个子功能的界面时,出现非法操作错误,然后程序终止。rn我也发现,当我的某个子功能的界面与数据库无关时,不会出现错误,可见错误还是出在数据库上。rn我该如何解决呢?请高手关注!rn
连接数据库出现问题啦!!
在与 SQL Server 建立连接时出现与网络相关的或特定于实例的错误。未找到或无法访问服务器。请验证实例名称是否正确并且 SQL Server 已配置为允许远程连接。 (provider: 命名管道提供程序, error: 40 - 无法打开到 SQL Server 的连接) (.Net SqlClient Data Provider)rn请问大家该怎么办?
ASP.net连接数据库出现问题!
编译通过后,在IE中运行后出现 "Login failed for user 'S\ASPNET'",其中S是计算机名,这是提示信息如下:rn堆栈跟踪: rnrnrn[SqlException: Login failed for user 'S\ASPNET'.]rn System.Data.SqlClient.ConnectionPool.GetConnection(Boolean& isInTransaction)rn System.Data.SqlClient.SqlConnectionPoolManager.GetPooledConnection(SqlConnectionString options, Boolean& isInTransaction)rn System.Data.SqlClient.SqlConnection.Open()rn CustomerInfo.WebForm1.bindGrid() in c:\inetpub\wwwroot\customerinfo\webform1.aspx.cs:37rn CustomerInfo.WebForm1.OnInit(EventArgs e) in c:\inetpub\wwwroot\customerinfo\webform1.aspx.cs:50rn System.Web.UI.Control.InitRecursive(Control namingContainer)rn System.Web.UI.Page.ProcessRequestMain()rnrn rn请问怎么办?我数据库是SQL SERVER 2000,rn             . rn
ruby连接数据库出现问题
我在连接数据库的时候用mysql depot_development
连接数据库时出现问题
我在Eclipse连接MySql数据库编译时出现:SQLExceptionNo suitable driver这样的一个错误,请教大家怎么解决.
JBuilder 9中连接数据库出现问题
能查询数据库(sql server2000),但是,不能更改,为什么呢?rn rnrn 出错信息如下:系统错误,请检测数据库!rn 我的代码如下:rnpackage card;rnrnimport java.awt.*;rnimport java.awt.event.*;rnimport javax.swing.*;rnimport java.sql.*;rnimport javax.swing.JPasswordField;rnimport com.borland.dx.sql.dataset.*;rnrn/**rn * Title: rn * Description: rn * Copyright: Copyright (c) 2003rn * Company: rn * @author not attributablern * @version 1.0rn */rnrnpublic class loginFrame extends JFrame rn JPanel contentPane;rn BorderLayout borderLayout1 = new BorderLayout();rn JPanel jPanel1 = new JPanel();rn JLabel jLabel1 = new JLabel();rn JLabel jLabel2 = new JLabel();rn JLabel jLabel3 = new JLabel();rn JTextField jTextField1 = new JTextField();rn JPasswordField jTextField2 = new JPasswordField();rn JButton jButton1 = new JButton();rn JButton jButton2 = new JButton();rn Database database1 = new Database();rn QueryDataSet queryDataSet1 = new QueryDataSet();rnrn //Construct the framern public loginFrame() rn enableEvents(AWTEvent.WINDOW_EVENT_MASK);rn try rn jbInit();rn rn catch(Exception e) rn e.printStackTrace();rn rn rn //Component initializationrn private void jbInit() throws Exception rn contentPane = (JPanel) this.getContentPane();rn contentPane.setLayout(borderLayout1);rn this.setSize(new Dimension(400, 300));rn this.setTitle("欢迎访问");rn jPanel1.setLayout(null);rn jLabel1.setFont(new java.awt.Font("Serif", 1, 40));rn jLabel1.setForeground(Color.blue);rn jLabel1.setHorizontalAlignment(SwingConstants.CENTER);rn jLabel1.setText("欢迎访问信用卡系统");rn jLabel1.setBounds(new Rectangle(0, 20, 400, 40));rnrn jLabel2.setFont(new java.awt.Font("Serif", 1, 16));rn jLabel2.setForeground(Color.blue);rn jLabel2.setHorizontalAlignment(SwingConstants.CENTER);rn jLabel2.setText("卡号:");rn jLabel2.setBounds(new Rectangle(100, 100, 60, 25));rnrn jLabel3.setFont(new java.awt.Font("Serif", 1, 16));rn jLabel3.setForeground(Color.blue);rn jLabel3.setHorizontalAlignment(SwingConstants.CENTER);rn jLabel3.setText("密码:");rn jLabel3.setBounds(new Rectangle(100, 160, 60, 25));rnrn jTextField1.setText("");rn jTextField1.setBounds(new Rectangle(160, 100, 140, 25));rnrn jTextField2.setText("");rn jTextField2.setBounds(new Rectangle(160, 160, 140, 25));rnrn jButton1.setBounds(new Rectangle(120, 220, 70, 25));rn jButton1.setText("确定");rn jButton1.addActionListener(new loginFrame_jButton1_actionAdapter(this));rnrn jButton2.setBounds(new Rectangle(210, 220, 70, 25));rn jButton2.setText("重置");rn jButton2.addActionListener(new loginFrame_jButton2_actionAdapter(this));rnrn //Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");rn //String url = "jdbc:microsoft:sqlserver://keweixing:1433;DatabaseName=dbcard";rn //String username= "sa";rn //String password= "";rn //con = DriverManager.getConnection(url,username,password);rnrn con = cardConnect.getconn(); //不用建立对象,直接调用cardConnect的方法rn loginQuery = "Select * from card where CardID = ? and Password =?";rn loginStmt = con.prepareStatement(loginQuery);rnrn contentPane.add(jPanel1, BorderLayout.CENTER);rn jPanel1.add(jLabel1, null);rn jPanel1.add(jLabel2, null);rn jPanel1.add(jTextField1, null);rn jPanel1.add(jButton1, null);rn jPanel1.add(jButton2, null);rn jPanel1.add(jLabel3, null);rn jPanel1.add(jTextField2, null);rn rn //Overridden so we can exit when window is closedrn protected void processWindowEvent(WindowEvent e) rn super.processWindowEvent(e);rn if (e.getID() == WindowEvent.WINDOW_CLOSING) rn System.exit(0);rn rn rnrn void jButton1_actionPerformed(ActionEvent e) rn tryrn CardID = jTextField1.getText(); //提取CardID的值rn loginStmt.setString(1, CardID); //给第一个主机变量赋值rn loginStmt.setString(2, jTextField2.getText()); //给第二个主机变量赋值(先提取密码值)rn ResultSet rs = loginStmt.executeQuery();rn if(rs.next()) //验证卡号和密码rn eventFrame eventFrame1 = new eventFrame(CardID);rn eventFrame1.setSize(new Dimension(400, 300));rn this.dispose();rn Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();rn Dimension frameSize = eventFrame1.getSize();rn eventFrame1.setState(eventFrame1.NORMAL);rn eventFrame1.setLocation( (screenSize.width - frameSize.width) / 2,rn (screenSize.height - frameSize.height) / 2);rn eventFrame1.show();rn rn elsern jTextField1.setText("卡号或密码错误。");rn jTextField2.setText("");//清空输入框并给出输入错误提示rn rn // finallyrn cardConnect.close(rs);rn cardConnect.close(loginStmt);rn cardConnect.close(con);rn // rn rn catch(SQLException ex) rn System.out.print("系统错误,请重新运行。");rn rn rnrn void jButton2_actionPerformed(ActionEvent e) rn jTextField1.setText("");rn jTextField2.setText("");rn rnrn private String CardID;rn private String loginQuery;rn private PreparedStatement loginStmt;rn private Connection con;rnrnrnclass loginFrame_jButton1_actionAdapter implements java.awt.event.ActionListener rn loginFrame adaptee;rnrn loginFrame_jButton1_actionAdapter(loginFrame adaptee) rn this.adaptee = adaptee;rn rn public void actionPerformed(ActionEvent e) rn adaptee.jButton1_actionPerformed(e);rn rnrnrnclass loginFrame_jButton2_actionAdapter implements java.awt.event.ActionListener rn loginFrame adaptee;rnrn loginFrame_jButton2_actionAdapter(loginFrame adaptee) rn this.adaptee = adaptee;rn rn public void actionPerformed(ActionEvent e) rn adaptee.jButton2_actionPerformed(e);rn rnrn
PHP连接数据库
对于mysql_connect()、mysql_query()、mysql_fetch_assoc()、mysql_close()等方法,由于文档上注明:本扩展自 PHP 5.5.0 起已废弃,并在将来会被移除。应使用xx扩展来替换之。所以下面用的都是mysqli_xx。      有两个php文件,分别是配置文件config.php,和处理文件demo.php。
php连接数据库
&amp;lt;?php     $conn=new mysqli('localhost','root','root','interface'); //数据库-地址,账号,密码(没有就为空),库名称     $conn-&amp;gt;query('set names utf8');//设置数据库语言     if($conn-&amp;gt;connect_error){          die(&quot;连接失败: &quot; ...
Php连接数据库下
课程基于PHP7.0的新特性全程代码实战讲解,适合没有任何编程基础或者PHP基础的同学学习。从基础的语法学习到相关的模块开发,以及数据库部分整个流程下来,大家可以学习到新的PHP开发技术。
php 连接数据库
//localhost.php//设置&amp;lt;?phpsession_start();header(&quot;Content-type:text/html;charset=utf-8&quot;);$con=mysql_connect('xxxxx','xxxx','xxxx');      //连接数据库mysql_query(&quot;set names 'utf8'&quot;);                //设置数据库...
PHP 连接数据库
初学 PHP ,写个简单的例子留着,说不定以后有用。 先准备一个数据库和一个信息表 为了方便查看,我加了个table <?php $conn = mysql_connect("localhost","1234","1234"); // 连接数据库服务器 (数据库地址,用户名,密码) mysql_query("set names 'utf-8'");
在线程中连接数据库出现问题呀
请问如何解决这个问题呀rnORACLE 数据库
连接数据库出现问题!!请大家帮忙~~~~
错误信息:java.sql.SQLException: [Microsoft][SQLServer 2000 Driver for JDBC]No ResultSet set was producedrnjava.sql.SQLException: [Microsoft][SQLServer 2000 Driver for JDBC]No ResultSet set was produced.rn at com.microsoft.jdbc.base.BaseExceptions.createException(Unknown Source)rn at com.microsoft.jdbc.base.BaseExceptions.getException(Unknown Source)rn at com.microsoft.jdbc.base.BaseStatement.executeQueryInternal(Unknown Source)rn at com.microsoft.jdbc.base.BaseStatement.executeQuery(Unknown Source)rn at aboutjsp.db.DbConnection.executeQuery(DbConnection.java:96)rn at aboutjsp.db.ViewQueryBean.executeQuery(ViewQueryBean.java:32)rn at _connectiondb__jsp._jspService(_connectiondb__jsp.java:108)rn at com.caucho.jsp.JavaPage.service(JavaPage.java:75)rn at com.caucho.jsp.Page.pageservice(Page.java:549)rn at com.caucho.server.dispatch.PageFilterChain.doFilter(PageFilterChain.java:184)rn at com.caucho.server.webapp.WebAppFilterChain.doFilter(WebAppFilterChain.java:149)rn at com.caucho.server.dispatch.ServletInvocation.service(ServletInvocation.java:221)rn at com.caucho.server.http.HttpRequest.handleRequest(HttpRequest.java:257)rn at com.caucho.server.port.WorkerThread.run(WorkerThread.java:123)rn at java.lang.Thread.run(Thread.java:536)rnrnrnrn
我用oracle8i+win2k 连接数据库出现问题,
String user="system";rn String pwd="manager";rn String sConnStr="jdbc:oracle:thin:@localhost:1521:orcl";rn Connection conn=null;rn ResultSet rs=null;rn rs=null;rn tryrn rn conn=DriverManager.getConnection(sConnStr,user,pwd);rn Statement stmt=conn.createStatement();rn rs=stmt.executeQuery(sql); rn rnerror:rnJava.SQL.Exception The Network Adapter could not establish the connection rnrn我用oracle8i+win2k 连接数据库出现问题,rn经oracle.com查是没有:rn1。Start the TNS listener rn2。Database server is not running on MTS Mode rn解决方法是找到了,但是怎么操作呢?rn还望高手赐教阿,呵呵rn
jsp初级问题,连接数据库出现问题.
<%@ page contentType="text/html; charset=GBK" %>rn<%@ page import="java.sql.*"%>rnrnrn 管理系统rnrnrn<%rnClass.forName("oracle.jdbc.driver.OracleDriver");rn%>rnrnrnrntype Exception reportrnrnmessage Internal Server Errorrnrndescription The server encountered an internal error (Internal Server Error) that prevented it from fulfilling this request.rnrnexception rnrnjavax.servlet.ServletException: oracle.jdbc.driver.OracleDriverrn
连接数据库,调试出现问题,继续求救
我在连数据库的语句中写的rntryrnrn_bstr_t strConnect="Provider=OraOLEDB.Oracle.1;User ID=HrSys;Data Source=OraDB;Persist Security Info=false";rnm_pConnection->Open(strConnect,"","",adModeUnknown);rnrnrn结果在调试的时候,说loaded 'ntdll.dll',no matching symbolic information foundrn loaded 'C:\windows\system32\MSIMTF.dll',no matching symbolic information foundrn等等类似的问题,然后说ACESS Violationrn结果登录框总是连不上。rn 晕阿~rn大家快来帮忙啊~
相关热词 c# xml的遍历循环 c# 取 查看源码没有的 c#解决高并发 委托 c#日期转化为字符串 c# 显示问号 c# 字典对象池 c#5.0 安装程序 c# 分页算法 c# gmail 发邮件 c# 多层文件