已有101人关注
动态查询以及增删改数据库控制台出现错误
还有0人有此问题
发表在Java图书答疑 2019-10-12 《零基础学Java》第14章 使用JDBC操作数据库
是否精华
版块置顶:

代码:

package 数据库连接;


import java.sql.*;


public class DongTai {


public static void main(String[] args) {

// TODO 自动生成的方法存根

Connection con = null;

try {

Class.forName("com.mysql.jdbc.Driver");

con = DriverManager.getConnection("jdbc:mysql://localhost:3306/lg",   //数据库连接已成功

"root","zxx15935930051gl");

String sql = "select *from zxx where name=? or gender=?";

PreparedStatement ps = con.prepareStatement(sql);

ps.setObject(1,"%");

ps.setObject(2,"男");

ResultSet res = ps.executeQuery();

System.out.println("name\tage\tgender\tjobtime");

while(res.next()) {   

System.out.println(res.getObject(1)+"\t"+res.getObject(2)+"\t"+res.getObject(3)+"\t"+res.getObject(4));

}

}catch (Exception e) {

e.printStackTrace();

}finally {

if(con!=null) {

try {

con.close();

} catch (SQLException e) {

// TODO 自动生成的 catch 块

e.printStackTrace();

}

}

}


}


}


控制台:<ConnectionProperties>

 <PropertyCategory name="Connection/Authentication">

  <Property name="user" required="No" default="" sortOrder="-2147483647" since="all versions">

    The user to connect as

  </Property>

  <Property name="password" required="No" default="" sortOrder="-2147483646" since="all versions">

    The password to use when connecting

  </Property>

  <Property name="socketFactory" required="No" default="com.mysql.jdbc.StandardSocketFactory" sortOrder="4" since="3.0.3">

    The name of the class that the driver should use for creating socket connections to the server. This class must implement the interface 'com.mysql.jdbc.SocketFactory' and have public no-args constructor.

  </Property>

  <Property name="connectTimeout" required="No" default="0" sortOrder="9" since="3.0.1">

    Timeout for socket connect (in milliseconds), with 0 being no timeout. Only works on JDK-1.4 or newer. Defaults to '0'.

  </Property>

  <Property name="socketTimeout" required="No" default="0" sortOrder="10" since="3.0.1">

    Timeout on network socket operations (0, the default means no timeout).

  </Property>

  <Property name="connectionLifecycleInterceptors" required="No" default="" sortOrder="2147483647" since="5.1.4">

    A comma-delimited list of classes that implement "com.mysql.jdbc.ConnectionLifecycleInterceptor" that should notified of connection lifecycle events (creation, destruction, commit, rollback, setCatalog and setAutoCommit) and potentially alter the execution of these commands. ConnectionLifecycleInterceptors are "stackable", more than one interceptor may be specified via the configuration property as a comma-delimited list, with the interceptors executed in order from left to right.

  </Property>

  <Property name="useConfigs" required="No" default="" sortOrder="2147483647" since="3.1.5">

    Load the comma-delimited list of configuration properties before parsing the URL or applying user-specified properties. These configurations are explained in the 'Configurations' of the documentation.

  </Property>

  <Property name="authenticationPlugins" required="No" default="" sortOrder="alpha" since="5.1.19">

    Comma-delimited list of classes that implement com.mysql.jdbc.AuthenticationPlugin and which will be used for authentication unless disabled by "disabledAuthenticationPlugins" property.

  </Property>

  <Property name="defaultAuthenticationPlugin" required="No" default="com.mysql.jdbc.authentication.MysqlNativePasswordPlugin" sortOrder="alpha" since="5.1.19">

    Name of a class implementing com.mysql.jdbc.AuthenticationPlugin which will be used as the default authentication plugin (see below). It is an error to use a class which is not listed in "authenticationPlugins" nor it is one of the built-in plugins. It is an error to set as default a plugin which was disabled with "disabledAuthenticationPlugins" property. It is an error to set this value to null or the empty string (i.e. there must be at least a valid default authentication plugin specified for the connection, meeting all constraints listed above).

  </Property>

  <Property name="disabledAuthenticationPlugins" required="No" default="" sortOrder="alpha" since="5.1.19">

    Comma-delimited list of classes implementing com.mysql.jdbc.AuthenticationPlugin or mechanisms, i.e. "mysql_native_password". The authentication plugins or mechanisms listed will not be used for authentication which will fail if it requires one of them. It is an error to disable the default authentication plugin (either the one named by "defaultAuthenticationPlugin" property or the hard-coded one if "defaultAuthenticationPlugin" property is not set).

  </Property>

  <Property name="disconnectOnExpiredPasswords" required="No" default="true" sortOrder="alpha" since="5.1.23">

    If "disconnectOnExpiredPasswords" is set to "false" and password is expired then server enters "sandbox" mode and sends ERR(08001, ER_MUST_CHANGE_PASSWORD) for all commands that are not needed to set a new password until a new password is set.

  </Property>

  <Property name="interactiveClient" required="No" default="false" sortOrder="alpha" since="3.1.0">

    Set the CLIENT_INTERACTIVE flag, which tells MySQL to timeout connections based on INTERACTIVE_TIMEOUT instead of WAIT_TIMEOUT

  </Property>

  <Property name="localSocketAddress" required="No" default="" sortOrder="alpha" since="5.0.5">

    Hostname or IP address given to explicitly configure the interface that the driver will bind the client side of the TCP/IP connection to when connecting.

  </Property>

  <Property name="propertiesTransform" required="No" default="" sortOrder="alpha" since="3.1.4">

    An implementation of com.mysql.jdbc.ConnectionPropertiesTransform that the driver will use to modify URL properties passed to the driver before attempting a connection

  </Property>

  <Property name="useCompression" required="No" default="false" sortOrder="alpha" since="3.0.17">

.................................................................后面还有一堆


2019-10-12 20:04:14编辑
分享到:
精彩评论 1
根号申
学分:4736 LV12
TA的每日心情
2021-07-16 23:48:46
2019-10-14
沙发

给出控制台的异常日志,我不知道你后面给的是什么,并不是控制台显示的内容。

首页上一页 1 下一页尾页 1 条记录 1/1页
手机同步功能介绍
友情提示:以下图书配套资源能够实现手机同步功能
明日微信公众号
明日之星 明日之星编程特训营
客服热线(每日9:00-17:00)
400 675 1066
mingrisoft@mingrisoft.com
吉林省明日科技有限公司Copyright ©2007-2022,mingrisoft.com, All Rights Reserved长春市北湖科技开发区盛北大街3333号长春北湖科技园项目一期A10号楼四、五层
吉ICP备10002740号-2吉公网安备22010202000132经营性网站备案信息 营业执照