语句,如下:
mysql>
SHOW
VARIABLES
LIKE
'%char%set%'
+--------------------------+----------------------------------+
|
Variable_name
|
Value
|
+--------------------------+----------------------------------+
|
character_set_client
|
utf8
|
|
character_set_connection
|
utf8
|
|
character_set_database
|
gbk
|
|
character_set_filesystem
|
binary
|
|
character_set_results
|
utf8
|
|
character_set_server
|
gbk
|
|
character_set_system
|
utf8
|
|
character_sets_dir
|
/u01/mysql/share/mysql/charsets/
|
+--------------------------+----------------------------------+
8
rows
in
set
mysql>
SHOW
VARIABLES
LIKE
'port'
+---------------+-------+
|
Variable_name
|
Value
|
+---------------+-------+
|
port
|
3306
|
+---------------+-------+
1
row
in
set
你如果想获取所有配置信息可以使用:
SHOW
VARIABLES命令。
1.jdbc.propertiesdriver=com.microsoft.jdbc.sqlserver.SQLServerDriver
url=jdbc:microsoft:sqlserver://Ip地址:1433databaseName=test
user=test
password=test
2.一个Servlet
import java.io.PrintStream
import java.sql.*
import java.util.ResourceBundle
public class DBOperator
{
public DBOperator()
{
}
public static void main(String args[])
{
Connection con = getConnection()
System.out.println("connection success")
closeConnection(con)
System.out.println("close success")
}
public static Connection getConnection()
{
try
{
return DriverManager.getConnection(url, user,
password)
}
catch(SQLException e)
{
e.printStackTrace()
}
return null
}
public static void closeConnection(Connection con)
{
try
{
if(con != null)
con.close()
}
catch(SQLException e)
{
e.printStackTrace()
}
}
private static String url
private static String user
private static String password
static
{
ResourceBundle bundle = ResourceBundle.getBundle("路径")
try
{
Class.forName(bundle.getString("driver"))
}
catch(ClassNotFoundException e)
{
e.printStackTrace()
}
url = bundle.getString("url")
user = bundle.getString("user")
password = bundle.getString("password")
}
}
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)