创建了一个新的数据库和新的表,show tables显示表已存在,但是select查询或desc都显示表不存在。

求解答
刚刚安装的MySQL 8.0.16版本 创建了一个新的数据库和新的表,show tables显示表已存在,但是select查询或desc都显示表不存在
Server version: 8.0.16 MySQL Community Server
系统MacOS

mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| e                  |
| information_schema |
| mysql              |
| performance_schema |
| sys                |
+--------------------+
5 rows in set (0.00 sec)

mysql> create database t;
Query OK, 1 row affected (0.00 sec)

mysql> CREATE TABLE ‘test_0’(
    -> ‘id’ int(11) unsigned NOT NULL AUTO_INCREMENT, 
    -> ‘name’ varchar(80) NOT NULL,
    -> PRIMARY KEY (‘id’)
    -> );
ERROR 1046 (3D000): No database selected
mysql> use t
Database changed
mysql> CREATE TABLE ‘test_0’(
    -> ‘id’ int(11) unsigned NOT NULL AUTO_INCREMENT, 
    -> ‘name’ varchar(80) NOT NULL,
    -> PRIMARY KEY (‘id’)
    -> );
Query OK, 0 rows affected (0.02 sec)

mysql> show tables;
+--------------+
| Tables_in_t  |
+--------------+
| ‘test_0’     |
+--------------+
1 row in set (0.00 sec)

mysql> desc test_0;
ERROR 1146 (42S02): Table 't.test_0' doesn't exist
mysql> 

1个回答

符号用错了,你现在的表名是‘test_0’不是test_0,mysql的表名跟字段名的特列符号是反引号 `

https://blog.csdn.net/wo541075754/article/details/52290000

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
其他相关推荐
查询页面,每次点击都会调取一次数据库,导致数据库重复调用
![图片说明](https://img-ask.csdn.net/upload/201911/28/1574938692_788093.png) 如图,现在的逻辑如下: ``` def dianji() 查询按钮.点击事件(duqu) 查询按钮.点击事件(show) (等于点击查询按钮的时候,同时执行两个方法) def luru() 写入数据库(用的sqlit3) def duqu() 读取数据库 def show() 从duqu函数里面调用数据,写进表格中 ``` 现在的问题就是,每次点击查询的时候,show和duqu都会执行一次,虽然数据库只有一组数据,但是每次点击,show这个函数都会把数据库里面仅有的一条数据重复读取,再次写入。 正确情况应该是我在艺人录入页面点击提交,然后点击查询才会多出来一条新数据,但是现在不管你点不点提交,数据库里面的数据总是给调一下并显示。(当然,只是显示,重启后写入的就没有了,但是也糟心啊) 现在不知道该咋整了。。。。新手,希望大佬可以文字描述一下。
keil C51 数码管的动态显示 延时问题
我在写数码管动态显示的时候发现意义相同的两个代码写出来显示的结果却不同,代码如下: ``` void display_SEG(unsigned int t) { Y_SEG_show(1, 2); while(t--); Y_SEG_show(2, 0); while(t--); Y_SEG_show(3, 1); while(t--); Y_SEG_show(4, 8); while(t--); Y_SEG_show(5, 16); while(t--); Y_SEG_show(6, 16); while(t--); Y_SEG_show(7, i/10); while(t--); Y_SEG_show(8, i%10); while(t--); } ``` t=500;上面这个运行起来延时时间明显过长,从而达不到余辉效应。 ``` void delay_SEG(unsigned char t) { while(t--); } void display_SEG() { Y_SEG_show(1, 2); delay_SEG(500); Y_SEG_show(2, 0); delay_SEG(500); Y_SEG_show(3, 1); delay_SEG(500); Y_SEG_show(4, 8); delay_SEG(500); Y_SEG_show(5, 16); delay_SEG(500); Y_SEG_show(6, 16); delay_SEG(500); Y_SEG_show(7, i/10); delay_SEG(500); Y_SEG_show(8, i%10); delay_SEG(500); } ``` 当定义一个延时函数放进去时,却可以达到效果,可用的不都是while(500--)的延迟吗,为什么会有这个差别。求解答
Druid连接SqlServer报错,为啥都连接了sqlserver还执行SHOW TABLES?
SpringBoot + Guns脚手架改成使用sqlserver,在最后时刻报错了,原因是sqlserver执行了mysql的语句SHOW TABLES,druid内部会执行这一句吗?mysql转sqlserver该如何实现? ``` 2019-12-09 15:04:10.196 INFO 3788 --- [ restartedMain] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/mgr/add]}" onto public cn.stylefeng.roses.core.reqres.response.ResponseData com.jsnjfz.manage.modular.system.controller.UserMgrController.add(com.jsnjfz.manage.modular.system.transfer.UserDto,org.springframework.validation.BindingResult) 2019-12-09 15:04:10.196 INFO 3788 --- [ restartedMain] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/mgr/delete]}" onto public cn.stylefeng.roses.core.reqres.response.ResponseData com.jsnjfz.manage.modular.system.controller.UserMgrController.delete(java.lang.Integer) 2019-12-09 15:04:10.196 INFO 3788 --- [ restartedMain] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/mgr/list]}" onto public java.lang.Object com.jsnjfz.manage.modular.system.controller.UserMgrController.list(java.lang.String,java.lang.String,java.lang.String,java.lang.Integer) 2019-12-09 15:04:10.196 INFO 3788 --- [ restartedMain] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/mgr/reset]}" onto public cn.stylefeng.roses.core.reqres.response.ResponseData com.jsnjfz.manage.modular.system.controller.UserMgrController.reset(java.lang.Integer) 2019-12-09 15:04:10.196 INFO 3788 --- [ restartedMain] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/mgr/user_info]}" onto public java.lang.String com.jsnjfz.manage.modular.system.controller.UserMgrController.userInfo(org.springframework.ui.Model) 2019-12-09 15:04:10.196 INFO 3788 --- [ restartedMain] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/mgr/freeze]}" onto public cn.stylefeng.roses.core.reqres.response.ResponseData com.jsnjfz.manage.modular.system.controller.UserMgrController.freeze(java.lang.Integer) 2019-12-09 15:04:10.196 INFO 3788 --- [ restartedMain] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/mgr/view/{userId}]}" onto public com.jsnjfz.manage.modular.system.model.User com.jsnjfz.manage.modular.system.controller.UserMgrController.view(java.lang.Integer) 2019-12-09 15:04:10.196 INFO 3788 --- [ restartedMain] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/mgr/setRole]}" onto public cn.stylefeng.roses.core.reqres.response.ResponseData com.jsnjfz.manage.modular.system.controller.UserMgrController.setRole(java.lang.Integer,java.lang.String) 2019-12-09 15:04:10.196 INFO 3788 --- [ restartedMain] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/mgr/user_chpwd]}" onto public java.lang.String com.jsnjfz.manage.modular.system.controller.UserMgrController.chPwd() 2019-12-09 15:04:10.196 INFO 3788 --- [ restartedMain] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/mgr/changePwd]}" onto public java.lang.Object com.jsnjfz.manage.modular.system.controller.UserMgrController.changePwd(java.lang.String,java.lang.String,java.lang.String) 2019-12-09 15:04:10.196 INFO 3788 --- [ restartedMain] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/mgr/edit]}" onto public cn.stylefeng.roses.core.reqres.response.ResponseData com.jsnjfz.manage.modular.system.controller.UserMgrController.edit(com.jsnjfz.manage.modular.system.transfer.UserDto,org.springframework.validation.BindingResult) throws javax.naming.NoPermissionException 2019-12-09 15:04:10.212 INFO 3788 --- [ restartedMain] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/mgr/role_assign/{userId}]}" onto public java.lang.String com.jsnjfz.manage.modular.system.controller.UserMgrController.roleAssign(java.lang.Integer,org.springframework.ui.Model) 2019-12-09 15:04:10.212 INFO 3788 --- [ restartedMain] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/mgr/user_add]}" onto public java.lang.String com.jsnjfz.manage.modular.system.controller.UserMgrController.addView() 2019-12-09 15:04:10.212 INFO 3788 --- [ restartedMain] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/mgr/user_edit/{userId}]}" onto public java.lang.String com.jsnjfz.manage.modular.system.controller.UserMgrController.userEdit(java.lang.Integer,org.springframework.ui.Model) 2019-12-09 15:04:10.212 INFO 3788 --- [ restartedMain] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/mgr/upload],methods=[POST]}" onto public java.lang.String com.jsnjfz.manage.modular.system.controller.UserMgrController.upload(org.springframework.web.multipart.MultipartFile) 2019-12-09 15:04:10.212 INFO 3788 --- [ restartedMain] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/mgr/unfreeze]}" onto public cn.stylefeng.roses.core.reqres.response.ResponseData com.jsnjfz.manage.modular.system.controller.UserMgrController.unfreeze(java.lang.Integer) 2019-12-09 15:04:10.212 INFO 3788 --- [ restartedMain] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/error]}" onto public org.springframework.http.ResponseEntity<java.util.Map<java.lang.String, java.lang.Object>> org.springframework.boot.autoconfigure.web.servlet.error.BasicErrorController.error(javax.servlet.http.HttpServletRequest) 2019-12-09 15:04:10.212 INFO 3788 --- [ restartedMain] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/error],produces=[text/html]}" onto public org.springframework.web.servlet.ModelAndView org.springframework.boot.autoconfigure.web.servlet.error.BasicErrorController.errorHtml(javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse) 2019-12-09 15:04:10.212 INFO 3788 --- [ restartedMain] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/code/generate],methods=[POST]}" onto public java.lang.Object cn.stylefeng.guns.generator.modular.controller.CodeController.generate(cn.stylefeng.guns.generator.executor.model.GenQo) 2019-12-09 15:04:10.212 INFO 3788 --- [ restartedMain] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/code]}" onto public java.lang.String cn.stylefeng.guns.generator.modular.controller.CodeController.blackboard(org.springframework.ui.Model) 2019-12-09 15:04:10.353 INFO 3788 --- [ restartedMain] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped URL path [/webjars/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler] 2019-12-09 15:04:10.353 INFO 3788 --- [ restartedMain] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped URL path [/static/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler] 2019-12-09 15:04:10.353 INFO 3788 --- [ restartedMain] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped URL path [/swagger-ui.html] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler] 2019-12-09 15:04:10.415 INFO 3788 --- [ restartedMain] .m.m.a.ExceptionHandlerExceptionResolver : Detected @ExceptionHandler methods in globalExceptionHandler 2019-12-09 15:04:10.415 INFO 3788 --- [ restartedMain] .m.m.a.ExceptionHandlerExceptionResolver : Detected @ExceptionHandler methods in defaultControllerExceptionHandler 2019-12-09 15:04:11.071 INFO 3788 --- [ restartedMain] o.s.b.d.a.OptionalLiveReloadServer : LiveReload server is running on port 35729 2019-12-09 15:04:11.114 INFO 3788 --- [ restartedMain] o.s.j.e.a.AnnotationMBeanExporter : Registering beans for JMX exposure on startup 2019-12-09 15:04:11.161 INFO 3788 --- [ restartedMain] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat started on port(s): 8001 (http) with context path '' 2019-12-09 15:04:11.161 INFO 3788 --- [ restartedMain] c.jsnjfz.manage.WebstackGunsApplication : Started WebstackGunsApplication in 71.82 seconds (JVM running for 72.932) JDBC Connection [com.alibaba.druid.proxy.jdbc.ConnectionProxyImpl@7a595887] will not be managed by Spring 2019-12-09 15:08:40.389 ERROR 3788 --- [ restartedMain] o.s.boot.SpringApplication : Application run failed com.baomidou.mybatisplus.exceptions.MybatisPlusException: java.lang.reflect.InvocationTargetException at com.baomidou.mybatisplus.MybatisSqlSessionTemplate$SqlSessionInterceptor.invoke(MybatisSqlSessionTemplate.java:405) at com.sun.proxy.$Proxy86.selectList(Unknown Source) at com.baomidou.mybatisplus.MybatisSqlSessionTemplate.selectList(MybatisSqlSessionTemplate.java:195) at com.baomidou.mybatisplus.mapper.SqlRunner.selectObjs(SqlRunner.java:140) at cn.stylefeng.roses.core.db.DbInitializer.initTable(DbInitializer.java:97) at cn.stylefeng.roses.core.db.DbInitializer.dbInit(DbInitializer.java:71) at cn.stylefeng.roses.core.db.listener.InitTableListener.onApplicationEvent(InitTableListener.java:42) at cn.stylefeng.roses.core.db.listener.InitTableListener.onApplicationEvent(InitTableListener.java:32) at org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:172) at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:165) at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:139) at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:400) at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:354) at org.springframework.boot.context.event.EventPublishingRunListener.running(EventPublishingRunListener.java:103) at org.springframework.boot.SpringApplicationRunListeners.running(SpringApplicationRunListeners.java:78) at org.springframework.boot.SpringApplication.run(SpringApplication.java:343) at org.springframework.boot.SpringApplication.run(SpringApplication.java:1255) at org.springframework.boot.SpringApplication.run(SpringApplication.java:1243) at com.jsnjfz.manage.WebstackGunsApplication.main(WebstackGunsApplication.java:36) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.springframework.boot.devtools.restart.RestartLauncher.run(RestartLauncher.java:49) Caused by: java.lang.reflect.InvocationTargetException: null at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at com.baomidou.mybatisplus.MybatisSqlSessionTemplate$SqlSessionInterceptor.invoke(MybatisSqlSessionTemplate.java:401) ... 23 common frames omitted Caused by: org.apache.ibatis.exceptions.PersistenceException: ### Error querying database. Cause: java.sql.SQLException: sql injection violation, syntax error: syntax error, error in :'SHOW TABLES', expect IDENTIFIER, actual IDENTIFIER pos 4, line 1, column 1, token IDENTIFIER SHOW : SHOW TABLES ### The error may involve com.baomidou.mybatisplus.mapper.SqlRunner.SelectObjs ### The error occurred while executing a query ### SQL: SHOW TABLES ### Cause: java.sql.SQLException: sql injection violation, syntax error: syntax error, error in :'SHOW TABLES', expect IDENTIFIER, actual IDENTIFIER pos 4, line 1, column 1, token IDENTIFIER SHOW : SHOW TABLES at org.apache.ibatis.exceptions.ExceptionFactory.wrapException(ExceptionFactory.java:30) at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:150) at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:141) ... 28 common frames omitted Caused by: java.sql.SQLException: sql injection violation, syntax error: syntax error, error in :'SHOW TABLES', expect IDENTIFIER, actual IDENTIFIER pos 4, line 1, column 1, token IDENTIFIER SHOW : SHOW TABLES at com.alibaba.druid.wall.WallFilter.checkInternal(WallFilter.java:798) at com.alibaba.druid.wall.WallFilter.connection_prepareStatement(WallFilter.java:251) at com.alibaba.druid.filter.FilterChainImpl.connection_prepareStatement(FilterChainImpl.java:568) at com.alibaba.druid.proxy.jdbc.ConnectionProxyImpl.prepareStatement(ConnectionProxyImpl.java:342) at com.alibaba.druid.pool.DruidPooledConnection.prepareStatement(DruidPooledConnection.java:349) at org.apache.ibatis.executor.statement.PreparedStatementHandler.instantiateStatement(PreparedStatementHandler.java:87) at org.apache.ibatis.executor.statement.BaseStatementHandler.prepare(BaseStatementHandler.java:88) at org.apache.ibatis.executor.statement.RoutingStatementHandler.prepare(RoutingStatementHandler.java:59) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.apache.ibatis.plugin.Invocation.proceed(Invocation.java:49) at com.baomidou.mybatisplus.plugins.PaginationInterceptor.intercept(PaginationInterceptor.java:112) at org.apache.ibatis.plugin.Plugin.invoke(Plugin.java:61) at com.sun.proxy.$Proxy114.prepare(Unknown Source) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.apache.ibatis.plugin.Invocation.proceed(Invocation.java:49) at cn.stylefeng.roses.core.datascope.DataScopeInterceptor.intercept(DataScopeInterceptor.java:46) at org.apache.ibatis.plugin.Plugin.invoke(Plugin.java:61) at com.sun.proxy.$Proxy114.prepare(Unknown Source) at org.apache.ibatis.executor.SimpleExecutor.prepareStatement(SimpleExecutor.java:85) at org.apache.ibatis.executor.SimpleExecutor.doQuery(SimpleExecutor.java:62) at org.apache.ibatis.executor.BaseExecutor.queryFromDatabase(BaseExecutor.java:326) at org.apache.ibatis.executor.BaseExecutor.query(BaseExecutor.java:156) at org.apache.ibatis.executor.CachingExecutor.query(CachingExecutor.java:109) at org.apache.ibatis.executor.CachingExecutor.query(CachingExecutor.java:83) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.apache.ibatis.plugin.Plugin.invoke(Plugin.java:63) at com.sun.proxy.$Proxy113.query(Unknown Source) at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:148) ... 29 common frames omitted Caused by: com.alibaba.druid.sql.parser.ParserException: syntax error, error in :'SHOW TABLES', expect IDENTIFIER, actual IDENTIFIER pos 4, line 1, column 1, token IDENTIFIER SHOW at com.alibaba.druid.sql.parser.SQLParser.printError(SQLParser.java:284) at com.alibaba.druid.sql.parser.SQLStatementParser.parseStatementList(SQLStatementParser.java:426) at com.alibaba.druid.sql.parser.SQLStatementParser.parseStatementList(SQLStatementParser.java:83) at com.alibaba.druid.wall.WallProvider.checkInternal(WallProvider.java:624) at com.alibaba.druid.wall.WallProvider.check(WallProvider.java:578) at com.alibaba.druid.wall.WallFilter.checkInternal(WallFilter.java:785) ... 65 common frames omitted 2019-12-09 15:08:40.394 INFO 3788 --- [ restartedMain] ConfigServletWebServerApplicationContext : Closing org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext@e8fcbe7: startup date [Mon Dec 09 15:02:59 CST 2019]; root of context hierarchy 2019-12-09 15:08:40.395 INFO 3788 --- [ restartedMain] o.s.j.e.a.AnnotationMBeanExporter : Unregistering JMX-exposed beans on shutdown 2019-12-09 15:08:40.395 INFO 3788 --- [ restartedMain] com.alibaba.druid.pool.DruidDataSource : {dataSource-1} closed 2019-12-09 15:08:40.395 INFO 3788 --- [ restartedMain] o.s.c.ehcache.EhCacheManagerFactoryBean : Shutting down EhCache CacheManager ```
数据库更新后,调用DataAdapter,DataSet和DataGridView显示数据库
``` public void ComonDataView_order_info() { try { DBConnect(); //连接数据库成功后的操作 //创建DataAdapter对象 SqlDataAdapter order_info_da = new SqlDataAdapter("select * from 订单详情", sqlCon); //创建数据集(也可以直接利用.NET的DataSet 数据适配器控件) DataSet order_info_ds = new DataSet(); order_info_da.AcceptChangesDuringFill = true; //Fill方法填充 order_info_da.Fill(order_info_ds); order_info_da.Update(order_info_ds); //将DataSet数据集绑定到DataGridView dataGridView1.AllowUserToAddRows = true; dataGridView1.DataSource = order_info_ds.Tables[0]; dataGridView1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells; //绑定数据源 dataGridView1.DataSource = order_info_ds.Tables[0].DefaultView; } catch (SystemException ex) { //连接数据库失败提示 MessageBox.Show("错误:" + ex.Message, "错误提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Information); } finally { //如果处于与数据库连接状态 if (sqlCon.State == ConnectionState.Open) { //关闭SQL连接 sqlCon.Close(); //释放所占用的资源 sqlCon.Dispose(); } } } ``` 如何实现每调用一次ComonDataView_order_info(),DataGridView就显示一次新的数据库内容? 为什么每插入一次数据,调用一次函数,但是只显示最后一次,其他时候都没有显示?
谁能帮我解释下这段mysql是做什么的?怎么查询数据库名为[ShFTZNQI]的相关跟踪语句?为什么这段查询会很慢
```mysql -- 临时开启慢查询日志 show variables like '%quer%'; set global slow_query_log=1; -- 临时开启慢查询时间 show variables like 'long_query_time'; set global long_query_time=1; -- 设置慢查询存储的方式 show variables like 'log_output'; set global log_output = 'FILE'; set global log_output = 'TABLE'; -- 设置查看日志 SELECT * FROM mysql.slow_log; SELECT * FROM mysql.general_log; select sleep(30); explain select ID from new_table; 清空sql日志 SET GLOBAL slow_query_log = 'OFF'; ALTER TABLE mysql.slow_log RENAME mysql.slow_log_drop; CREATE TABLE mysql.slow_log LIKE mysql.slow_log_drop; SET GLOBAL slow_query_log = 'ON'; DROP TABLE mysql.slow_log_drop; SELECT * FROM mysql.slow_log order by start_time desc ```
eclipse连接数据库出错
问题如下: eclipse能加载数据库驱动,却不能连接 ![图片说明](https://img-ask.csdn.net/upload/201910/31/1572530581_866255.png) eclipse、mysql环境配置都没问题 数据库版本是8.0以上 驱动程序mysql-connector-java-8.0.16放的位置也没错 mysql可以用控制台操作 mysql服务已启动 用户名是root 密码123456 ``` C:\Users\HP>mysql -uroot -p Enter password: ****** Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 23 Server version: 8.0.17 MySQL Community Server - GPL ``` 创建好了database student ``` mysql> show databases; +--------------------+ | Database | +--------------------+ | information_schema | | mysql | | performance_schema | | register | | student | | sys | +--------------------+ 6 rows in set (0.00 sec) ``` 搞了半天头都大了,这块搞不定下面的javaweb根本没法学,求大佬指导。
Porcelain Exhibitions 怎么编的程序
Problem Description Recently, the Chinese government is going to hold a porcelain exhibition in every province. For fascinating citizens, each exhibition should put at least MIN_K porcelains on show. And by the restriction of conditions, at most MAX_K porcelains can be shown in an exhibition. The number of porcelains in a province is in direct proportion to the area of that province. So some small provinces may don't have enough porcelains, and some big provinces may have more porcelains than it can show(having too much porcelains is not a problem for holding an exhibition, just don’t show some of them). The government decides to transport some porcelains between provinces so that every province can hold an exhibition. Because of the limitation of traffic, the amount of porcelains passing a boundary between two provinces is limited. So the government asks you to write a program to manage the transportation. The map of China can be seen as a connected planar graph embedded on a plane. Each face of the graph represents a province. This graph has N vertices and M edges. A vertex of the graph is also a point on the map, and an edge is also a line segment connecting two points, meaning a boundary between two provinces. Input The input will consist of multiply test cases. For each case, The first line contains five positive integers --- above mentioned N, M, MIN_K,MAX_K and P( N <= 1000,M <= 10000, MIN_K < MAX_K) . P means that if the area of a province is A, then there are A×P porcelains in that province. P is guaranteed to be even so that the amount of porcelains in each province will be a positive integer. The next N lines, each gives two integer x, y, representing the coordinate of a vertex(Vertexes have distinct coordinates). The vertexes are numbered from 0 to N-1 and the coordinates are given in the order of vertex No. The next M lines, each gives three integers u,v, and w. It means that there is an edge connecting vertex u and vertex v. The edge is also a boundary between two provinces. w means that the boundary can’t let more than w porcelains to pass through. (w for the boundary of China is 0, and boundaries don't overlap). The number of province is less than 2000. Unsigned int is enough for this problem. The input ends with 0 0 0 0 0. Output For each test case, print one integer in a line representing the maximal number of porcelains can be exhibited in whole country. If one or more province can’t hold an exhibition, print -1. Sample Input 8 9 5 8 2 0 0 0 3 3 3 3 0 1 1 1 2 2 2 2 1 0 1 0 1 2 0 2 3 0 3 0 0 4 5 1 5 6 1 6 7 1 7 4 1 0 4 1 8 9 7 8 2 0 0 0 3 3 3 3 0 1 1 1 2 2 2 2 1 0 1 0 1 2 0 2 3 0 3 0 0 4 5 1 5 6 1 6 7 1 7 4 1 0 4 1 0 0 0 0 0 Sample Output 14 -1
用MATLAB实现BP神经网络对二手车价格的预测误差很大
基于BP神经网络建立了二手车价格预测模型,建立的双隐层结构。 思路为根据二手的品牌、里程、车龄等信息预测二手车价格。共3500条数据,3000训练,500调试。 但是不管怎么调试一直误差很大。求大神帮忙调试一下,怎么降低误差。 ``` clear; clc; % 清空环境变量 % 原始数据 %名字 name = xlsread('E:\毕业论文\Data\瓜子二手车数据处理.xlsx','A1:A3000'); %新车指导价 new_price = xlsread('E:\毕业论文\Data\瓜子二手车数据处理.xlsx','B1:B3000'); %表现里程 mileage = xlsread('E:\毕业论文\Data\瓜子二手车数据处理.xlsx','C1:C3000'); %排放标准 discharge = xlsread('E:\毕业论文\Data\瓜子二手车数据处理.xlsx','D1:D3000'); %变速箱类型 transmission_case = xlsread('E:\毕业论文\Data\瓜子二手车数据处理.xlsx','E1:E3000'); %排量 displacement = xlsread('E:\毕业论文\Data\瓜子二手车数据处理.xlsx','F1:F3000'); %过户次数 transfer = xlsread('E:\毕业论文\Data\瓜子二手车数据处理.xlsx','G1:G3000'); %车龄 age = xlsread('E:\毕业论文\Data\瓜子二手车数据处理.xlsx','H1:H3000'); %二手车价格 price = xlsread('E:\毕业论文\Data\瓜子二手车数据处理.xlsx','I1:I3000'); %目标数据 ptest = xlsread('E:\毕业论文\Data\瓜子二手车数据处理.xlsx','A3001:H3475'); ptest = ptest'; ttest = xlsread('E:\毕业论文\Data\瓜子二手车数据处理.xlsx','I3001:I3475'); ttest = ttest'; % 输入数据矩阵 p = [name';new_price';mileage';discharge';transmission_case';displacement';transfer';age']; %输入目标矩阵 t = [price']; %数据归一化 [pn, minp, maxp, tn, mint, maxt] = premnmx(p, t); %隐含层节点数 NodeNum1 = 20; NodeNum2 = 20; %输出维数 TypeNum = 1; TF1 = 'tansig'; TF2 = 'tansig'; TF3 = 'tansig'; net = newff(minmax(pn),[NodeNum1,NodeNum2,TypeNum],{TF1 TF2 TF3},'traingdx'); %网络创建traingdm %每间隔50步显示一次训练 net.trainParam.show = 50; %最大训练次数 net.trainParam.epochs = 50000; %训练所要达到的精度 net.trainParam.goal = 1e-4; %学习速率 net.trainParam.lr = 0.0001; %最小梯度 net.trainParam.min_grad = 1e-15; net = train(net,pn,tn); %测试数据的归一化 p2n = tramnmx(ptest,minp,maxp); an = sim(net,p2n); %数据的反归一化,即最终想得到的预测结果 [a] = postmnmx(an,mint,maxt); plot(1:length(ttest),ttest,'o',1:length(ttest),a,'+'); title('o表示预测值--- *表示实际值'); grid on m = length(a); t1 = [ttest]; error = (t1-a)./a; figure plot(1:length(error),error,'o'); title('误差变化图'); grid on ``` 结果图片是: ![图片说明](https://img-ask.csdn.net/upload/202001/14/1578988212_623706.jpg) ![图片说明](https://img-ask.csdn.net/upload/202001/14/1578988228_219711.jpg) 数据截图![图片说明](https://img-ask.csdn.net/upload/202001/14/1578988287_246300.png)
用spyder库pymysql调用mysql数据库时出现的ProgrammingError: (1007, 'Unknown error 1007')如何解决?
大一学生, 今天第一次使用pymysql ``` import pymysql conn = pymysql.connect(host='localhost',user='root',passwd='*******',charset='utf8') cursor = conn.cursor() dbName='test' sql = 'show databases' cursor.execute(sql) dbs = cursor.fetchall() for db in dbs: if dbName in db: cursor.execute('drop database '+dbName) break cursor.execute('create database ' +dbName) conn.select_db(dbName) ``` 用vscode调试到这里就运行不下去了 报错 ProgrammingError: (1007, 'Unknown error 1007') 有高手能帮帮忙吗?
springboot 配置hibernate 开始使用的是mysql,都正常,但是换成Oracle后总是创建表。
springboot 配置hibernate 开始使用的是mysql,都正常,但是换成Oracle后总是创建表。所以后台报如下表重复错误。这是为什么呀?应该是如果发现表已经有的话不应该再创建才对,请帮我看下哪里配置错了。 再详细说明下我的场景: 数据库映射的对象Product。 第一次系统启动肯定会创建一个,因为数据库中是没有这个表,然后系统重启或者再次启动,正常来讲,Product对象没有改过,数据库表也存在,hibernate不应该再创建,但是目前就是再创建,所以报表名已经有的错误。 ``` Caused by: java.sql.SQLSyntaxErrorException: ORA-00955: 名称已由现有对象使用 at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:447) ~[ojdbc-6.6.0.jar:11.2.0.4.0] at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:396) ~[ojdbc-6.6.0.jar:11.2.0.4.0] at oracle.jdbc.driver.T4C8Oall.processError(T4C8Oall.java:951) ~[ojdbc-6.6.0.jar:11.2.0.4.0] ``` ``` server: port: 8001 spring: application: name: DEMO_TEST #f服务名称定义 datasource: type: com.alibaba.druid.pool.DruidDataSource # 当前数据源操作类型 #driver-class-name: com.mysql.cj.jdbc.Driver # mysql驱动包 driver-class-name: oracle.jdbc.driver.OracleDriver #url: jdbc:mysql://127.0.0.1:3306/rd_plm?serverTimezone=GMT%2B8 # 数据库名称 url: jdbc:oracle:thin:@127.0.0.1:1521/DD username: root password: root dbcp2: min-idle: 5 # 数据库连接池的最小维持连接数 initial-size: 5 # 初始化连接数 max-total: 5 # 最大连接数 max-wait-millis: 150 # 等待连接获取的最大超时时间 jpa: hibernate: naming: physical-strategy: org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl ddl-auto: update show-sql: true properties: hibernate: #dialect: org.hibernate.dialect.MariaDBDialect dialect: org.hibernate.dialect.OracleDialect current_session_context_class: org.springframework.orm.hibernate5.SpringSessionContext #database: MYSQL database: oracle open-in-view: true ```
求查改代码,数据库和vs2010的
我从网上复制了一个增删查改的例子,但是只有增和删。没有查和改,, 我设置第5个button,求大神写下里面的改代码。, 另外查代码例子说(// 查询数据还是运用SQL语句较好。使用 SqlCommand对象即可) 什么意思?,是说查询只能在数据库里面查,VS2010不能查询吗? 以下是网上的代码,可以运行。。 using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using System.Data.SqlClient; namespace TEXT6 { public partial class Form1 : Form { SqlConnection con = new SqlConnection("Server=.;Database=student1;integrated security=SSPI");//创建一个数据库连接,·代表服务器在本地 SqlDataAdapter da;//创建一个数据容器 DataSet ds;//建一个接受数据库返回结果集的容器 SqlCommandBuilder cb; string tablename = "student1"; public Form1() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { da = new SqlDataAdapter("select * from " + tablename, con); ds = new DataSet(); da.Fill(ds, tablename); dataGridView1.DataSource = ds.Tables[tablename]; } private void button2_Click(object sender, EventArgs e) { DataRow dr = ds.Tables[tablename].NewRow(); dr[0] = textBox1.Text;//给第一个字段赋值 dr[1] = textBox2.Text;//给第二个字段赋值 dr[2] = textBox3.Text; dr[3] = textBox4.Text; ds.Tables[tablename].Rows.Add(dr);//将新行添加到表中 // 调用提交更新程序 } private void button3_Click(object sender, EventArgs e) { string message = "是否真的要删除该行,并不可恢复?"; string caption = "警告提示"; DialogResult result; int w = dataGridView1.CurrentCell.RowIndex; //当前鼠标点击的所在行 result = MessageBox.Show(this, message, caption, MessageBoxButtons.YesNo, MessageBoxIcon.Warning); if (result == DialogResult.Yes) { DataRowCollection dr = ds.Tables[tablename].Rows; dr[w].Delete(); } } private void button4_Click(object sender, EventArgs e) { SqlCommandBuilder cb = new SqlCommandBuilder(da); da.Update(ds, tablename); MessageBox.Show("更新成功!"); ds.Tables[tablename].AcceptChanges(); } private void textBox1_TextChanged(object sender, EventArgs e) { } private void textBox2_TextChanged(object sender, EventArgs e) { } private void button5_Click(object sender, EventArgs e) { } } } button5是我另外拖进去的,但是我不会写代码,,改的代码怎么写,,大神求教!!!
JS换行保存后,不显示换行,显示的却是字符<br>
![图片说明](https://img-ask.csdn.net/upload/202001/12/1578817782_338780.png) 缺陷内容保存后可以换行显示,处理结果就不可以,就显示<br> ``` function getAdd() { var w=$(window).width(); var h=$(window).height(); $('#dd').dialog({ title: '添加缺陷记录', width: w * .6, height: h - 136, closed: false, cache: false, href: 'dia/log/defect-record/get-add.html?module_id=' + module_id + '&station_info=' + station_info, modal: true, buttons: [{ text: '保存', iconCls: "easy-icon-save", handler: function () { var shift = $("#reportShift").combobox("getValue"); if(shift == -1 || shift == ""){ $.messager.alert('操作', '请重新核对缺陷上报日期以及所选班次'); return false; } checkStation("station");//检测是否选择或输入 var defectLevel = $('#defectLevel').combobox('getValue'); if (defectLevel == 0 || defectLevel == 1) { var planTime = $('#planProTime').datebox('getValue'); if (planTime == null || planTime == '') { $.messager.alert("修改", "计划处理时间不能为空!", "error"); return; } } var data = $("#defect-add-form").serialize(); // var content = $('#content').val().replace(/\n/g,"<br/>"); $.ajax({ url: "dia/log/defect-record/insert.do?module_id=" + module_id + '&proResult=' + $('#proResult').val().replace(/\r\n/g, '<br/>').replace(/\n/g, '<br/>').replace(/\s/g, ' '), type : "post", dataType : "json", data : data, success : function(request) { if(request.success){ query(); } $.messager.show({ title: '操作提示', msg: request.msg, timeout: 2000, sshowType: 'slide' }); } }); $("#dd").dialog({ closed: true }); } }, { text: '关闭', iconCls: "easy-icon-cancel", handler: function () { $("#dd").dialog({ closed: true }); } }], //用于图形化,窗口打开完成后,给厂站赋值 onLoad: function () { var indexDevId = $("#indexDevId").val(); $('#station').combobox('setValue', indexDevId); } }); } ``` 这是JSP代码 ``` <tr> <td class="td-inputtitle" style="text-align: center">处理结果</td> <td class="td-input" colspan="5" > <c:forEach var="item" items="${historyProcess }"> <c:if test="${item.proResult!=null && item.proResult!='' }"> <div class="history_process"> <div class="user_info">${item.userName }<br/>${item.time }</div> <div class="content" >${fn:replace(item.proResult,vEnter,'<br>') } </div> <div class="clearfix"></div> </div> </c:if> </c:forEach> <textarea type="text" rows="6" name="proResult" id="proResult" style="width:95%;"> ${currProcess.proResult } </textarea> </td> </tr> ```
这个利用sqlite写的数据库为什么退出应用后再进去数据库就无法找到了啊
package com.sample.Sample_8_4; import android.app.Activity; import android.app.AlertDialog; import android.content.ContentValues; import android.content.DialogInterface; import android.database.Cursor; import android.database.sqlite.SQLiteDatabase; import android.os.Bundle; import android.view.View; import android.view.View.OnClickListener; import android.widget.Button; import android.widget.Toast; public class Sample_8_4 extends Activity { private Button baseButton; private Button tableButton; private Button btn_sqlmod, btn_cvmod, btn_qur; private final String dbName = "mydb"; private final String tableName = "users"; private SQLiteDatabase db = null; private int i = 1; public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); this.setContentView(R.layout.main); baseButton = (Button) findViewById(R.id.base); // 实例化Button对象 baseButton.setOnClickListener(new OnClickListener() { // 为Button对象添加监听 public void onClick(View v) { db = openOrCreateDatabase(dbName, MODE_PRIVATE, null); // 创建名为“mydb”的数据库 db.endTransaction(); Toast.makeText(getApplicationContext(), "创建数据库成功", 1000) .show(); } }); tableButton = (Button) findViewById(R.id.table); // 实例化Button对象 tableButton.setOnClickListener(new OnClickListener() { // 为Button对象添加监听 public void onClick(View v) { if (db != null) { creatTable(); // 开始创建数据库表 } else { Toast.makeText(getApplicationContext(), "没有数据库", 1000).show(); } } }); btn_sqlmod = (Button) findViewById(R.id.sql_mod); btn_sqlmod.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub if (db != null) { sql_executeData(); } else { Toast.makeText(getApplicationContext(), "没有数据库", 1000) .show(); } } }); btn_cvmod = (Button) findViewById(R.id.cv_mod); btn_cvmod.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub if (db != null) { cv_executeData(); } else { Toast.makeText(getApplicationContext(), "没有数据库", 1000) .show(); } } }); btn_qur = (Button) findViewById(R.id.que); btn_qur.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub if (db != null) { queryData(); } else { Toast.makeText(getApplicationContext(), "没有数据库", 1000) .show(); } } }); } public void creatTable() { // 创建表的SQL语句,创建一个名为users的表,该表有id,uname和pwd三个字段 String sql = "CREATE TABLE IF NOT EXISTS " + tableName + " (id INTEGER PRIMARY KEY AUTOINCREMENT, uname VARCHAR(50), pwd VARCHAR(50));"; db.execSQL(sql); // 执行sql语句 db.endTransaction(); // 查询sqlite_master表中类型为table的记录的name字段 Cursor cursor = db.query("sqlite_master", new String[] { "name" }, "type = ?", new String[] { "table" }, null, null, null, null); String tables = ""; if (cursor.getCount() != 0) { // 判断查询结果的条数是否为0 cursor.moveToFirst(); // 游标指向第一条记录 for (int i = 0; i < cursor.getCount(); i += 1) { tables = tables + cursor.getString(0) + " "; // 累加字符串 cursor.moveToNext(); // 游标下移 } } // 把累加的结果显示在一个信息框中 new AlertDialog.Builder(Sample_8_4.this).setTitle("Message") .setMessage(tables) .setNegativeButton("确定", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { } }).show(); } public void sql_executeData() { String sql; for (; i < 4; i++) { sql = "insert into " + tableName + " values ('" + i + "','a','123456')"; // 添加一条记录 db.execSQL(sql); db.endTransaction(); } sql = "update " + tableName + " set pwd='654321' where id='1'"; // 修改一条记录 db.execSQL(sql); db.endTransaction(); sql = "delete from " + tableName + " where id='2'"; // 删除一条记录 db.execSQL(sql); db.endTransaction(); Toast.makeText(getApplicationContext(), "使用SQL语句修改数据成功", 1000).show(); } public void cv_executeData() { ContentValues cv = new ContentValues(); // 实例化ContentValues对象 cv.put("uname", "b"); // 插入字段值 cv.put("pwd", "987654"); // 插入字段值 db.insert(tableName, null, cv); // 执行insert方法 db.insert(tableName, null, cv); // 执行insert方法 db.insert(tableName, null, cv); // 执行insert方法 cv = new ContentValues(); // 实例化ContentValues对象 cv.put("pwd", "456789"); // 插入字段值 db.update(tableName, cv, "id=?", new String[] { "4" }); // 执行update方法 db.delete(tableName, "id=?", new String[] { "5" }); // 执行delete操作 Toast.makeText(getApplicationContext(), "使用Android语句修改数据成功", 1000) .show(); } public void queryData() { Cursor cursor = db.query(tableName, null, null, null, null, null, null, null); // 执行query操作获得Cursor对象 String str = ""; if (cursor.getCount() != 0) { // 判断返回的记录条数 cursor.moveToFirst(); // 游标指向第一条记录 for (int i = 0; i < cursor.getCount(); i += 1) { str = str + cursor.getString(0) + " " + cursor.getString(1) + " " + cursor.getString(2) + "\n"; // 获取一条记录的每个字段的值 cursor.moveToNext(); // 游标指向下一条记录 } } // 在信息框上显示所有记录信息 new AlertDialog.Builder(Sample_8_4.this).setTitle("Message") .setMessage(str) .setNegativeButton("确定", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { } }).show(); } }
.net+vue+iview新手提问
初次使用vue+iview做项目所以有些低级问题与要大佬们赐教 我在iview官网粘贴的table组件的代码,在按钮的地方官网上给的是这样的 render(row, column, index) { return `<i-button type="primary" size="small" @click="show(${index})">查看</i-button> <i-button type="error" size="small" @click="remove(${index})">删除</i-button>`; } 编译后会报一个错误![图片说明](https://img-ask.csdn.net/upload/202001/11/1578728087_242827.png) 当我把代码换成这样的时候 render(row, column, index) { return `<i-button type="primary" size="small" @@click="show(${index})">查看</i-button> <i-button type="error" size="small" @@click="remove(${index})">删除</i-button>`; } 他会有这样的问题![图片说明](https://img-ask.csdn.net/upload/202001/11/1578728193_374614.png) 所以我想知道table按钮那个该怎么解决 这是我的代码,大佬们求指点 ``` @{ Layout = null; } <!DOCTYPE html> <html> <head> <meta name="viewport" content="width=device-width" /> <title>用户管理</title> <script src="~/Scripts/vue.js"></script> <script src="~/Scripts/IView/iview.js"></script> <link href="~/Content/Iview/iview.css" rel="stylesheet" /> <script> export default { data() { return { self: this, columns7: [ { title: '姓名', key: 'name', render(row, column, index) { return `<Icon type="person"></Icon> <strong>${row.name}</strong>`; } }, { title: '年龄', key: 'age' }, { title: '地址', key: 'address' }, { title: '操作', key: 'action', width: 150, align: 'center', render(row, column, index) { return `<i-button type="primary" size="small" @@click="show(${index})">查看</i-button> <i-button type="error" size="small" @@click="remove(${index})">删除</i-button>`; } } ], data6: [ { name: '王小明', age: 18, address: '北京市朝阳区芍药居' }, { name: '张小刚', age: 25, address: '北京市海淀区西二旗' }, { name: '李小红', age: 30, address: '上海市浦东新区世纪大道' }, { name: '周小伟', age: 26, address: '深圳市南山区深南大道' } ] } }, methods: { show(index) { this.$Modal.info({ title: '用户信息', content: `姓名:${this.data6[index].name}<br>年龄:${this.data6[index].age}<br>地址:${this.data6[index].address}` }) }, remove(index) { this.data6.splice(index, 1); } } } </script> </head> <body> <template> <i-table border :content="self" :columns="columns7" :data="data6" ></i-table> </template> </body> </html> ```
win32程序怎么连接数据库并验证正确性
###运行后虽然有界面出现,但是输入了用户名和密码后就卡住了一会,然后退出了,messagebox也没有显示,求大佬点拨,下面是代码: ``` #include <windows.h> #include "resource.h" //....... //资源 BOOL REGISTEWIN(HINSTANCE hInstance,LPSTR lpClassName, WNDPROC wndProc); void SHOWWND(HWND hwnd); void MESSAGE(); void Link(); LRESULT CALLBACK MYPROC(HWND hwnd,UINT msg,WPARAM wparam,LPARAM lparam); LRESULT CALLBACK SCREEAN1PROC(HWND hwnd,UINT msg,WPARAM wparam,LPARAM lparam); LRESULT CALLBACK DialogProc1(HWND hwnd,UINT msg,WPARAM wparam,LPARAM lparam); BOOL Check(SQLHSTMT hStmt); HWND hwndup; HWND hwnd; RETCODE retcode; HINSTANCE hInstance; SQLHENV henv = SQL_NULL_HENV; SQLHDBC hdbc1 = SQL_NULL_HDBC; SQLHSTMT hstmt1 = SQL_NULL_HSTMT; char users[255]={0}; char password[255]={0}; //winmain主程序 int WinMain(HINSTANCE hInstance,HINSTANCE hinstance,LPSTR lpCmdLine,int nShowCmd){ char* name = "name"; char* screen1 = "screen1"; //创建对话框,并判断对话框是否注册成功 HWND hdlg = CreateDialog(hInstance,MAKEINTRESOURCE(IDD_DIALOG2),GetDesktopWindow(),(DLGPROC)DialogProc1); if(!hdlg) MessageBox(hwnd,"error","error",MB_OK); SHOWWND(hdlg); //创建管理界面 hwndup = CreateWindow(screen1,TEXT("图书管理界面"),WS_OVERLAPPEDWINDOW,500,100,500,700,NULL,LoadMenu(hInstance,MAKEINTRESOURCE(IDR_MENU1)),hInstance,NULL) ; MESSAGE(); return 0; } //DialogProc1函数 LRESULT CALLBACK DialogProc1(HWND hdlg,UINT msg,WPARAM wparam,LPARAM lparam){ switch (msg) { case WM_INITDIALOG: return TRUE; case WM_COMMAND: { switch (LOWORD(wparam)) { case IDOK: { HWND h1=NULL; HWND h2=NULL; h1=GetDlgItem(hdlg,0x00009c40) ; h2=GetDlgItem(hdlg,0x00009c41) ; if(h1==NULL&&h2==NULL) printf("GetDlgItem fail!"); //获得user和password SendMessage(h1,WM_GETTEXT,255,(LPARAM)users); SendMessage(h2,WM_GETTEXT,255,(LPARAM)password); printf("%s %s\n",users,password); // // //就是这里,,,,想通过数据库查找user和password // // if(Check(hdlg)==TRUE) MessageBox(hdlg,"error","账户或密码不正确",MB_OK); DestroyWindow(hdlg); hdlg = NULL; hdlg = CreateDialog(hInstance,MAKEINTRESOURCE(IDD_DIALOG1),hwnd,(DLGPROC)DialogProc1); ShowWindow(hdlg,SW_SHOW); } break; case IDCANCEL: { //点击取消按钮关闭对话框,最后关闭窗口 EndDialog(hdlg, IDCANCEL); } break; } } break; case WM_SYSCOMMAND: { if (wparam == SC_CLOSE) { EndDialog(hdlg,TRUE); } } break; } return (INT_PTR)FALSE; } //检查user和password函数 BOOL Check(SQLHSTMT hStmt) { Link(); char * person1 = "select *from Login where users='"; const char * person2 = "' and password="; strcat(person1,users); strcat(person1,person2); strcat(person1,password); SQLRETURN ret = SQLExecDirect(hStmt,(SQLCHAR*)person1,strlen(person1)); if (ret == SQL_SUCCESS) return TRUE; else return FALSE; } void MESSAGE(){ MSG msg = {0}; while(GetMessage(&msg,NULL,0,0)){ TranslateMessage(&msg); DispatchMessage(&msg);//分发消息,将消息分发给回调函数,回调函数callback处理完后,返回给dispatchmessage函数,再继续进行消息循环 } } void Link(){ // UCHAR szDSN[SQL_MAX_DSN_LENGTH+1] = "db_mrbm",//数据源名称 szUID[MAXNAME] = "sa", szAuthStr[MAXNAME] = "0922"; //1.连接数据源 //1.环境句柄 retcode = SQLAllocHandle(SQL_HANDLE_ENV,NULL,&henv); retcode = SQLSetEnvAttr(henv,SQL_ATTR_ODBC_VERSION,(SQLPOINTER)SQL_OV_ODBC3,SQL_IS_INTEGER); //2.连接句柄 retcode = SQLAllocHandle(SQL_HANDLE_DBC,henv, &hdbc1); retcode = SQLConnect(hdbc1, szDSN, 13, szUID, 2, szAuthStr,4); //判断连接是否成功 if((retcode!=SQL_SUCCESS)&&(retcode!=SQL_SUCCESS_WITH_INFO)){ MessageBox(hwnd,"连接错误","error",MB_OK); }else{printf("连接!/n");} // } ```
SSH连接数据库时,无法自动创建表,且tomcat无法启动
jdbc配置: driverClass=com.mysql.jdbc.Driver url=jdbc:mysql://localhost:3306/mydata user=root password=root 当数据库中没有mydata表时,无法自动创建,且tomcat启动不了,停留在Initializing Spring root WebApplicationContext。如果手动创建mydata表,tomcat可以启动,项目也能运行。 hibernate配置: <!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN" "http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd"> <hibernate-configuration> <session-factory> <!-- 数据库言 --> <property name="hibernate.dialect">org.hibernate.dialect.SQLServerDialect</property> <!-- 加载二级缓存插件(可选) --> <property name="hibernate.cache.region.factory_class">org.hibernate.cache.EhCacheRegionFactory</property> <property name="hibernate.cache.use_query_cache">true</property> <!-- 配置自动生成DDL语句 --> <property name="hibernate.hbm2ddl.auto">update</property> <!-- 在控制台打印出当前的sql语句 --> <property name="hibernate.show_sql">true</property> <!-- 注册对象关系映射 --> </session-factory> </hibernate-configuration>
我想把保存在一个txt文件中的数据调用到一个类不知道如何成立
case 8:cout<<"\t\t此步是调用文件中的信息"<<endl; { ifstream readFile("课程设计保存.txt"); system("pause"); } break; //这是需要调用的文件名 class lesson { public: string date; int turn; string name; string type; void add() { cin>>date; cin>>turn; cin>>name; cin>>type; } void show(); void show1(); void allshow(); }; class student:public lesson { public: int count=0; int num; string name; string sex; int age; int classroom; lesson a[10]; void add(); void show(); void show1(); void show2(); void allshow(); void addlesson(); void save(); }; student stu[1000]; //怎么调用到这个lei'z
安卓开发JDBC连接数据库No static method metafactory错误怎么解决?
直接上代码 JdbcUtil类 ``` package com.example.myapplication; import java.io.File; import java.io.FileInputStream; import java.sql.Connection; import java.sql.DriverManager; import java.util.Properties; public class JdbcUtil { private static JdbcUtil instance; public static JdbcUtil getInstance(){ if (instance ==null){ instance = new JdbcUtil(); } return instance; } public Connection getConnection(String dbName,String name,String password) { try { new com.mysql.cj.jdbc.Driver(); String url = "jdbc:mysql://localhost:3306/"+dbName; return DriverManager.getConnection(url,name,password); } catch (Exception e) { return null; } } public Connection getConnection(String file){ File f = new File(file); if(!f.exists()){ return null; }else { Properties pro = new Properties(); try { Class.forName("com.mysql.jdbc.Driver"); pro.load(new FileInputStream(f)); String url = pro.getProperty("url"); String name = pro.getProperty("name"); String password = pro.getProperty("password"); return DriverManager.getConnection(url,name,password); }catch (Exception e){ return null; } } } } ``` UserDao类 ``` package com.example.myapplication; import android.util.Log; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; import static android.content.ContentValues.TAG; public class UserDao { JdbcUtil jdbcUtil = JdbcUtil.getInstance(); //第一个参数为数据库名称,第二个参数为数据库账号 第三个参数为数据库密码 Connection conn = jdbcUtil.getConnection("test","root","LHMbdbqandr2015"); //注册 public boolean register(String name,String password){ if (conn==null){ Log.i(TAG,"register:conn is null"); return false; }else { //进行数据库操作 String sql = "insert into user(name,password) values(?,?)"; try { PreparedStatement pre = conn.prepareStatement(sql); pre.setString(1,name); pre.setString(2,password); return pre.execute(); } catch (SQLException e) { return false; }finally { try { conn.close(); } catch (SQLException e) { e.printStackTrace(); } } } } //登录 public boolean login(String name,String password){ if (conn==null){ Log.i(TAG,"register:conn is null"); return false; }else { String sql = "select * from user where name=? and password=?"; try { PreparedStatement pres = conn.prepareStatement(sql); pres.setString(1,name); pres.setString(2,password); ResultSet res = pres.executeQuery(); boolean t = res.next(); return t; } catch (SQLException e) { return false; } } } } ``` MainActivity文件 ``` package com.example.myapplication; import android.Manifest; import android.content.Intent; import android.content.pm.PackageManager; import android.os.Build; import android.os.Bundle; import android.os.Looper; import android.os.Trace; import android.util.Log; import android.view.View; import android.widget.EditText; import android.widget.Toast; import androidx.appcompat.app.AppCompatActivity; public class MainActivity extends AppCompatActivity { private static final String TAG="MainActivity"; private EditText name; private EditText password; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); name = findViewById(R.id.name); password = findViewById(R.id.password); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { if (checkSelfPermission(Manifest.permission.INTERNET) != PackageManager.PERMISSION_GRANTED) { // TODO: Consider calling // Activity#requestPermissions requestPermissions(new String[]{Manifest.permission.INTERNET},1); // here to request the missing permissions, and then overriding // public void onRequestPermissionsResult(int requestCode, String[] permissions, // int[] grantResults) // to handle the case where the user grants the permission. See the documentation // for Activity#requestPermissions for more details. return; } } } //用户根据点击事件来找到相应的功能 public void fun(View v){ switch (v.getId()){ case R.id.register: new Thread(new Runnable() { @Override public void run() { String n = name.getText().toString().trim(); String psw = password.getText().toString().trim(); UserDao ud = new UserDao(); boolean result =ud.register(n,psw); if (!result){ Looper.prepare(); Toast toast = Toast.makeText(MainActivity.this,"注册成功!",Toast.LENGTH_SHORT); toast.show(); Looper.loop(); } Log.i(TAG,"fun"+result); //以上为jdbc注册 } }).start(); break; case R.id.login: new Thread(new Runnable() { @Override public void run() { String n = name.getText().toString().trim(); String psw = password.getText().toString().trim(); if (n.equals("")||psw.equals("")){ Looper.prepare(); Toast toast = Toast.makeText(MainActivity.this,"输入不能为空!",Toast.LENGTH_SHORT); toast.show(); Looper.loop(); } UserDao ud = new UserDao(); Boolean result = ud.login(n,psw); if (!result){ Looper.prepare(); Toast toast=Toast.makeText(MainActivity.this,"用户名不存在或密码错误!",Toast.LENGTH_SHORT); toast.show(); Looper.loop(); }else{ Looper.prepare(); Toast toast=Toast.makeText(MainActivity.this,"登录成功",Toast.LENGTH_SHORT); toast.show(); //一下代码为跳转界面 // Intent intent=new Intent(MainActivity.this,info.class); //intent.putExtra("name",n); // startActivity(intent); Looper.loop(); } //以上为jdbc登录 } }).start(); } } } ``` 现在遇到的问题如下 ``` 11/14 01:40:49: Launching 'app' on Nexus 5X API 29 x86. $ adb shell am start -n "com.example.myapplication/com.example.myapplication.MainActivity" -a android.intent.action.MAIN -c android.intent.category.LAUNCHER Waiting for process to come online... Connected to process 23852 on device 'emulator-5554'. Capturing and displaying logcat messages from application. This behavior can be disabled in the "Logcat output" section of the "Debugger" settings page. I/e.myapplicatio: Not late-enabling -Xcheck:jni (already on) E/e.myapplicatio: Unknown bits set in runtime_flags: 0x8000 W/e.myapplicatio: Unexpected CPU variant for X86 using defaults: x86 D/libEGL: Emulator has host GPU support, qemu.gles is set to 1. W/libc: Unable to set property "qemu.gles" to "1": connection failed; errno=13 (Permission denied) W/RenderThread: type=1400 audit(0.0:129): avc: denied { write } for name="property_service" dev="tmpfs" ino=8368 scontext=u:r:untrusted_app:s0:c130,c256,c512,c768 tcontext=u:object_r:property_socket:s0 tclass=sock_file permissive=0 app=com.example.myapplication D/libEGL: loaded /vendor/lib/egl/libEGL_emulation.so D/libEGL: loaded /vendor/lib/egl/libGLESv1_CM_emulation.so D/libEGL: loaded /vendor/lib/egl/libGLESv2_emulation.so W/e.myapplicatio: Accessing hidden method Landroid/view/View;->computeFitSystemWindows(Landroid/graphics/Rect;Landroid/graphics/Rect;)Z (greylist, reflection, allowed) Accessing hidden method Landroid/view/ViewGroup;->makeOptionalFitsSystemWindows()V (greylist, reflection, allowed) D/: HostConnection::get() New Host Connection established 0xd7d24f50, tid 23910 D/: HostComposition ext ANDROID_EMU_CHECKSUM_HELPER_v1 ANDROID_EMU_native_sync_v2 ANDROID_EMU_native_sync_v3 ANDROID_EMU_dma_v1 ANDROID_EMU_direct_mem ANDROID_EMU_host_composition_v1 ANDROID_EMU_host_composition_v2 ANDROID_EMU_vulkan ANDROID_EMU_deferred_vulkan_commands ANDROID_EMU_vulkan_null_optional_strings ANDROID_EMU_vulkan_create_resources_with_requirements ANDROID_EMU_YUV420_888_to_NV21 ANDROID_EMU_YUV_Cache GL_OES_EGL_image_external_essl3 GL_OES_vertex_array_object GL_KHR_texture_compression_astc_ldr ANDROID_EMU_gles_max_version_3_1 W/OpenGLRenderer: Failed to choose config with EGL_SWAP_BEHAVIOR_PRESERVED, retrying without... D/eglCodecCommon: setVertexArrayObject: set vao to 0 (0) 0 0 D/EGL_emulation: eglCreateContext: 0xe3340b60: maj 3 min 1 rcv 4 D/EGL_emulation: eglMakeCurrent: 0xe3340b60: ver 3 1 (tinfo 0xe338bc10) E/eglCodecCommon: glUtilsParamSize: unknow param 0x000082da glUtilsParamSize: unknow param 0x000082da W/Gralloc3: mapper 3.x is not supported D/: createUnique: call D/: HostConnection::get() New Host Connection established 0xd7d26ad0, tid 23910 HostComposition ext ANDROID_EMU_CHECKSUM_HELPER_v1 ANDROID_EMU_native_sync_v2 ANDROID_EMU_native_sync_v3 ANDROID_EMU_dma_v1 ANDROID_EMU_direct_mem ANDROID_EMU_host_composition_v1 ANDROID_EMU_host_composition_v2 ANDROID_EMU_vulkan ANDROID_EMU_deferred_vulkan_commands ANDROID_EMU_vulkan_null_optional_strings ANDROID_EMU_vulkan_create_resources_with_requirements ANDROID_EMU_YUV420_888_to_NV21 ANDROID_EMU_YUV_Cache GL_OES_EGL_image_external_essl3 GL_OES_vertex_array_object GL_KHR_texture_compression_astc_ldr ANDROID_EMU_gles_max_version_3_1 D/eglCodecCommon: allocate: Ask for block of size 0x1000 D/eglCodecCommon: allocate: ioctl allocate returned offset 0x3ffff6000 size 0x2000 D/EGL_emulation: eglMakeCurrent: 0xe3340b60: ver 3 1 (tinfo 0xe338bc10) D/eglCodecCommon: setVertexArrayObject: set vao to 0 (0) 0 0 I/AssistStructure: Flattened final assist data: 1788 bytes, containing 1 windows, 10 views W/e.myapplicatio: Accessing hidden method Ljava/lang/invoke/LambdaMetafactory;->metafactory(Ljava/lang/invoke/MethodHandles$Lookup;Ljava/lang/String;Ljava/lang/invoke/MethodType;Ljava/lang/invoke/MethodType;Ljava/lang/invoke/MethodHandle;Ljava/lang/invoke/MethodType;)Ljava/lang/invoke/CallSite; (blacklist, linking, denied) E/AndroidRuntime: FATAL EXCEPTION: Thread-2 Process: com.example.myapplication, PID: 23852 java.lang.NoSuchMethodError: No static method metafactory(Ljava/lang/invoke/MethodHandles$Lookup;Ljava/lang/String;Ljava/lang/invoke/MethodType;Ljava/lang/invoke/MethodType;Ljava/lang/invoke/MethodHandle;Ljava/lang/invoke/MethodType;)Ljava/lang/invoke/CallSite; in class Ljava/lang/invoke/LambdaMetafactory; or its super classes (declaration of 'java.lang.invoke.LambdaMetafactory' appears in /apex/com.android.runtime/javalib/core-oj.jar) at com.mysql.cj.conf.ConnectionUrl.buildConnectionStringCacheKey(ConnectionUrl.java:246) at com.mysql.cj.conf.ConnectionUrl.getConnectionUrlInstance(ConnectionUrl.java:185) at com.mysql.cj.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:204) at java.sql.DriverManager.getConnection(DriverManager.java:580) at java.sql.DriverManager.getConnection(DriverManager.java:218) at com.example.myapplication.JdbcUtil.getConnection(JdbcUtil.java:22) at com.example.myapplication.UserDao.<init>(UserDao.java:15) at com.example.myapplication.MainActivity$1.run(MainActivity.java:53) at java.lang.Thread.run(Thread.java:919) D/EGL_emulation: eglMakeCurrent: 0xe3340b60: ver 3 1 (tinfo 0xe338bc10) D/AutofillManager: onActivityFinishing(): calling cancelLocked() Process 23852 terminated. ``` 在网上百度了很多方法都没有解决,起初以为是驱动的问题,但是换了一个仍然不好用,求求大神赐教
安卓调用百度地图sdk,可是返回坐标值一直是4.9E-324
我发现手机端使用正常,就是在使用夜神模拟器的时候出现的这样的问题。 打开夜神模拟器设置,发现我的软件有这个位置权限(手机端申请了动态权限) 但就是返回4.9E-324,location.getLocType()的返回值是167.我看文档说是没有获取到位置权限。 我现在就有一点迷惑了,动态的也申请了,也在AndroidManifest里面写了权限。 真心不知道这个bug咋解决。 以下是我mainactivity里面所有的代码: ``` package com.example.ppgo; import android.Manifest; import android.content.pm.PackageManager; import android.os.Bundle; import android.util.Log; import android.widget.TextView; import android.widget.Toast; import com.baidu.location.BDLocation; import com.baidu.location.BDLocationListener; import com.baidu.location.LocationClient; import com.baidu.location.LocationClientOption; import java.util.ArrayList; import java.util.List; import androidx.annotation.NonNull; import androidx.appcompat.app.AppCompatActivity; import androidx.core.app.ActivityCompat; import androidx.core.content.ContextCompat; public class MainActivity extends AppCompatActivity { public LocationClient mLocationClient; private TextView positionText; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mLocationClient=new LocationClient(getApplicationContext()); mLocationClient.registerLocationListener(new MyLocationListener()); setContentView(R.layout.activity_main); positionText=(TextView)findViewById(R.id.position_text_view); List<String> permissionList=new ArrayList<>(); if(ContextCompat.checkSelfPermission(MainActivity.this, Manifest. permission.ACCESS_FINE_LOCATION)!=PackageManager.PERMISSION_GRANTED){ permissionList.add(Manifest.permission.ACCESS_FINE_LOCATION); } if(ContextCompat.checkSelfPermission(MainActivity.this, Manifest. permission.READ_PHONE_STATE)!=PackageManager.PERMISSION_GRANTED){ permissionList.add(Manifest.permission.READ_PHONE_STATE); } if(ContextCompat.checkSelfPermission(MainActivity.this, Manifest. permission.WRITE_EXTERNAL_STORAGE)!=PackageManager.PERMISSION_GRANTED){ permissionList.add(Manifest.permission.WRITE_EXTERNAL_STORAGE); } if(!permissionList.isEmpty()){ String[]permissions=permissionList.toArray(new String[permissionList.size()]); ActivityCompat.requestPermissions(MainActivity.this,permissions,1); }else { requestLocation(); } } private void requestLocation(){ initLocation(); mLocationClient.start(); } private void initLocation(){ LocationClientOption option =new LocationClientOption(); option.setScanSpan(5000); mLocationClient.setLocOption(option); } @Override protected void onDestroy() { super.onDestroy(); mLocationClient.stop(); } @Override public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) { super.onRequestPermissionsResult(requestCode, permissions, grantResults); Log.e("Tag","执行了onRequestPermissionsResult函数"); switch (requestCode){ case 1: if (grantResults.length>0){ for(int result:grantResults){ if(result!=PackageManager.PERMISSION_GRANTED){ Toast.makeText(this,"必须同意所有权限才能使用本程序", Toast.LENGTH_SHORT).show(); finish(); return; } } requestLocation(); }else { Toast.makeText(this,"发生未知错误",Toast.LENGTH_SHORT).show(); finish(); } break; default: } } public class MyLocationListener implements BDLocationListener { @Override public void onReceiveLocation(BDLocation location){ StringBuilder currentPosition=new StringBuilder(); currentPosition.append("纬度:").append(location.getLatitude()).append("\n"); currentPosition.append("经线:").append(location.getLongitude()).append("\n"); currentPosition.append("国家:").append(location.getCountry()).append("\n"); currentPosition.append("省:").append(location.getProvince()).append("\n"); currentPosition.append("市:").append(location.getCity()).append("\n"); currentPosition.append("区:").append(location.getDistrict()).append("\n"); currentPosition.append("街道:").append(location.getStreet()).append("\n"); currentPosition.append("定位方式:"); if (location.getLocType() == BDLocation.TypeGpsLocation) { currentPosition.append("GPS"); } else if (location.getLocType() == BDLocation.TypeNetWorkLocation) { currentPosition.append("网络"); currentPosition.append(" 错误代码:"+location.getLocType()); } else if (location.getLocType() == BDLocation.TypeOffLineLocation){ currentPosition.append("离线定位成功,离线定位结果也是有效的"); } else if (location.getLocType() == BDLocation.TypeServerError){ currentPosition.append("服务端网络定位失败"); currentPosition.append(" 错误代码:"+location.getLocType()); } else if (location.getLocType() == BDLocation.TypeNetWorkException){ currentPosition.append("网络不同导致定位失败,请检查网络是否通畅"); } else if (location.getLocType() == BDLocation.TypeCriteriaException){ currentPosition.append("无法获取有效定位依据导致定位失败"); currentPosition.append(" 错误代码:"+location.getLocType()); } else { currentPosition.append(location.getLocType()); //这里打印出来location.getLocType()是162 currentPosition.append("老子也不知道是啥原因!!!"); } positionText.setText(currentPosition); } } } ``` 以下是我AndroidManifest里面的代码: ``` <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.example.ppgo"> <!-- 这个权限用于进行网络定位 --> <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" /> <!-- 这个权限用于访问GPS定位 --> <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /> <!-- 用于访问wifi网络信息,wifi信息会用于进行网络定位 --> <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" /> <!-- 获取网络状态,根据网络状态切换进行数据请求网络转换 --> <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> <!-- 写外置存储。如果开发者使用了离线地图,并且数据写在外置存储区域,则需要申请该权限 --> <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> <!-- 读取外置存储。如果开发者使用了so动态加载功能并且把so文件放在了外置存储区域,则需要申请该权限,否则不需要 --> <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" /> <!-- 访问网络,进行地图相关业务数据请求,包括地图数据,路线规划,POI检索等 --> <uses-permission android:name="android.permission.INTERNET" /> <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" /> <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /> <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" /> <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> <uses-permission android:name="android.permission.CHANGE_WIFI_MULTICAST_STATE" /> <uses-permission android:name="android.permission.READ_PHONE_STATE" /> <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> <uses-permission android:name="android.permission.INTERNET" /> <uses-permission android:name="android.permission.MOUNT_UNMOUNT_FILESYSTEMS" /> <uses-permission android:name="android.permission.WAKE_LOCK" /> <application android:allowBackup="true" android:icon="@mipmap/ic_launcher" android:label="@string/app_name" android:roundIcon="@mipmap/ic_launcher_round" android:supportsRtl="true" android:theme="@style/AppTheme"> <meta-data android:name="com.baidu.lbsapi.API_KEY" android:value="mvxMsdG1homIlK4UjAWYP2itjxo09Dyy" /> <activity android:name=".MainActivity"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> <service android:name="com.baidu.location.f" android:enabled="true" android:process=":remote" /> </application> </manifest> ```
Java学习的正确打开方式
在博主认为,对于入门级学习java的最佳学习方法莫过于视频+博客+书籍+总结,前三者博主将淋漓尽致地挥毫于这篇博客文章中,至于总结在于个人,实际上越到后面你会发现学习的最好方式就是阅读参考官方文档其次就是国内的书籍,博客次之,这又是一个层次了,这里暂时不提后面再谈。博主将为各位入门java保驾护航,各位只管冲鸭!!!上天是公平的,只要不辜负时间,时间自然不会辜负你。 何谓学习?博主所理解的学习,它是一个过程,是一个不断累积、不断沉淀、不断总结、善于传达自己的个人见解以及乐于分享的过程。
程序员必须掌握的核心算法有哪些?
由于我之前一直强调数据结构以及算法学习的重要性,所以就有一些读者经常问我,数据结构与算法应该要学习到哪个程度呢?,说实话,这个问题我不知道要怎么回答你,主要取决于你想学习到哪些程度,不过针对这个问题,我稍微总结一下我学过的算法知识点,以及我觉得值得学习的算法。这些算法与数据结构的学习大多数是零散的,并没有一本把他们全部覆盖的书籍。下面是我觉得值得学习的一些算法以及数据结构,当然,我也会整理一些看过...
有哪些让程序员受益终生的建议
从业五年多,辗转两个大厂,出过书,创过业,从技术小白成长为基层管理,联合几个业内大牛回答下这个问题,希望能帮到大家,记得帮我点赞哦。 敲黑板!!!读了这篇文章,你将知道如何才能进大厂,如何实现财务自由,如何在工作中游刃有余,这篇文章很长,但绝对是精品,记得帮我点赞哦!!!! 一腔肺腑之言,能看进去多少,就看你自己了!!! 目录: 在校生篇: 为什么要尽量进大厂? 如何选择语言及方...
大学四年自学走来,这些私藏的实用工具/学习网站我贡献出来了
大学四年,看课本是不可能一直看课本的了,对于学习,特别是自学,善于搜索网上的一些资源来辅助,还是非常有必要的,下面我就把这几年私藏的各种资源,网站贡献出来给你们。主要有:电子书搜索、实用工具、在线视频学习网站、非视频学习网站、软件下载、面试/求职必备网站。 注意:文中提到的所有资源,文末我都给你整理好了,你们只管拿去,如果觉得不错,转发、分享就是最大的支持了。 一、电子书搜索 对于大部分程序员...
linux系列之常用运维命令整理笔录
本博客记录工作中需要的linux运维命令,大学时候开始接触linux,会一些基本操作,可是都没有整理起来,加上是做开发,不做运维,有些命令忘记了,所以现在整理成博客,当然vi,文件操作等就不介绍了,慢慢积累一些其它拓展的命令,博客不定时更新 free -m 其中:m表示兆,也可以用g,注意都要小写 Men:表示物理内存统计 total:表示物理内存总数(total=used+free) use...
比特币原理详解
一、什么是比特币 比特币是一种电子货币,是一种基于密码学的货币,在2008年11月1日由中本聪发表比特币白皮书,文中提出了一种去中心化的电子记账系统,我们平时的电子现金是银行来记账,因为银行的背后是国家信用。去中心化电子记账系统是参与者共同记账。比特币可以防止主权危机、信用风险。其好处不多做赘述,这一层面介绍的文章很多,本文主要从更深层的技术原理角度进行介绍。 二、问题引入 假设现有4个人...
程序员接私活怎样防止做完了不给钱?
首先跟大家说明一点,我们做 IT 类的外包开发,是非标品开发,所以很有可能在开发过程中会有这样那样的需求修改,而这种需求修改很容易造成扯皮,进而影响到费用支付,甚至出现做完了项目收不到钱的情况。 那么,怎么保证自己的薪酬安全呢? 我们在开工前,一定要做好一些证据方面的准备(也就是“讨薪”的理论依据),这其中最重要的就是需求文档和验收标准。一定要让需求方提供这两个文档资料作为开发的基础。之后开发...
网页实现一个简单的音乐播放器(大佬别看。(⊙﹏⊙))
今天闲着无事,就想写点东西。然后听了下歌,就打算写个播放器。 于是乎用h5 audio的加上js简单的播放器完工了。 演示地点演示 html代码如下` music 这个年纪 七月的风 音乐 ` 然后就是css`*{ margin: 0; padding: 0; text-decoration: none; list-...
Python十大装B语法
Python 是一种代表简单思想的语言,其语法相对简单,很容易上手。不过,如果就此小视 Python 语法的精妙和深邃,那就大错特错了。本文精心筛选了最能展现 Python 语法之精妙的十个知识点,并附上详细的实例代码。如能在实战中融会贯通、灵活使用,必将使代码更为精炼、高效,同时也会极大提升代码B格,使之看上去更老练,读起来更优雅。
数据库优化 - SQL优化
以实际SQL入手,带你一步一步走上SQL优化之路!
2019年11月中国大陆编程语言排行榜
2019年11月2日,我统计了某招聘网站,获得有效程序员招聘数据9万条。针对招聘信息,提取编程语言关键字,并统计如下: 编程语言比例 rank pl_ percentage 1 java 33.62% 2 cpp 16.42% 3 c_sharp 12.82% 4 javascript 12.31% 5 python 7.93% 6 go 7.25% 7 p...
通俗易懂地给女朋友讲:线程池的内部原理
餐盘在灯光的照耀下格外晶莹洁白,女朋友拿起红酒杯轻轻地抿了一小口,对我说:“经常听你说线程池,到底线程池到底是个什么原理?”
《奇巧淫技》系列-python!!每天早上八点自动发送天气预报邮件到QQ邮箱
将代码部署服务器,每日早上定时获取到天气数据,并发送到邮箱。 也可以说是一个小型人工智障。 知识可以运用在不同地方,不一定非是天气预报。
经典算法(5)杨辉三角
杨辉三角 是经典算法,这篇博客对它的算法思想进行了讲解,并有完整的代码实现。
英特尔不为人知的 B 面
从 PC 时代至今,众人只知在 CPU、GPU、XPU、制程、工艺等战场中,英特尔在与同行硬件芯片制造商们的竞争中杀出重围,且在不断的成长进化中,成为全球知名的半导体公司。殊不知,在「刚硬」的背后,英特尔「柔性」的软件早已经做到了全方位的支持与支撑,并持续发挥独特的生态价值,推动产业合作共赢。 而对于这一不知人知的 B 面,很多人将其称之为英特尔隐形的翅膀,虽低调,但是影响力却不容小觑。 那么,在...
腾讯算法面试题:64匹马8个跑道需要多少轮才能选出最快的四匹?
昨天,有网友私信我,说去阿里面试,彻底的被打击到了。问了为什么网上大量使用ThreadLocal的源码都会加上private static?他被难住了,因为他从来都没有考虑过这个问题。无独有偶,今天笔者又发现有网友吐槽了一道腾讯的面试题,我们一起来看看。 腾讯算法面试题:64匹马8个跑道需要多少轮才能选出最快的四匹? 在互联网职场论坛,一名程序员发帖求助到。二面腾讯,其中一个算法题:64匹...
面试官:你连RESTful都不知道我怎么敢要你?
干货,2019 RESTful最贱实践
为啥国人偏爱Mybatis,而老外喜欢Hibernate/JPA呢?
关于SQL和ORM的争论,永远都不会终止,我也一直在思考这个问题。昨天又跟群里的小伙伴进行了一番讨论,感触还是有一些,于是就有了今天这篇文。 声明:本文不会下关于Mybatis和JPA两个持久层框架哪个更好这样的结论。只是摆事实,讲道理,所以,请各位看官勿喷。 一、事件起因 关于Mybatis和JPA孰优孰劣的问题,争论已经很多年了。一直也没有结论,毕竟每个人的喜好和习惯是大不相同的。我也看...
白话阿里巴巴Java开发手册高级篇
不久前,阿里巴巴发布了《阿里巴巴Java开发手册》,总结了阿里巴巴内部实际项目开发过程中开发人员应该遵守的研发流程规范,这些流程规范在一定程度上能够保证最终的项目交付质量,通过在时间中总结模式,并推广给广大开发人员,来避免研发人员在实践中容易犯的错误,确保最终在大规模协作的项目中达成既定目标。 无独有偶,笔者去年在公司里负责升级和制定研发流程、设计模板、设计标准、代码标准等规范,并在实际工作中进行...
SQL-小白最佳入门sql查询一
不要偷偷的查询我的个人资料,即使你再喜欢我,也不要这样,真的不好;
redis分布式锁,面试官请随便问,我都会
文章有点长并且绕,先来个图片缓冲下! 前言 现在的业务场景越来越复杂,使用的架构也就越来越复杂,分布式、高并发已经是业务要求的常态。像腾讯系的不少服务,还有CDN优化、异地多备份等处理。 说到分布式,就必然涉及到分布式锁的概念,如何保证不同机器不同线程的分布式锁同步呢? 实现要点 互斥性,同一时刻,智能有一个客户端持有锁。 防止死锁发生,如果持有锁的客户端崩溃没有主动释放锁,也要保证锁可以正常释...
项目中的if else太多了,该怎么重构?
介绍 最近跟着公司的大佬开发了一款IM系统,类似QQ和微信哈,就是聊天软件。我们有一部分业务逻辑是这样的 if (msgType = "文本") { // dosomething } else if(msgType = "图片") { // doshomething } else if(msgType = "视频") { // doshomething } else { // doshom...
Nginx 原理和架构
Nginx 是一个免费的,开源的,高性能的 HTTP 服务器和反向代理,以及 IMAP / POP3 代理服务器。Nginx 以其高性能,稳定性,丰富的功能,简单的配置和低资源消耗而闻名。 Nginx 的整体架构 Nginx 里有一个 master 进程和多个 worker 进程。master 进程并不处理网络请求,主要负责调度工作进程:加载配置、启动工作进程及非停升级。worker 进程负责处...
Python 编程开发 实用经验和技巧
Python是一门很灵活的语言,也有很多实用的方法,有时候实现一个功能可以用多种方法实现,我这里总结了一些常用的方法和技巧,包括小数保留指定位小数、判断变量的数据类型、类方法@classmethod、制表符中文对齐、遍历字典、datetime.timedelta的使用等,会持续更新......
YouTube排名第一的励志英文演讲《Dream(梦想)》
Idon’t know what that dream is that you have, I don't care how disappointing it might have been as you've been working toward that dream,but that dream that you’re holding in your mind, that it’s po...
“狗屁不通文章生成器”登顶GitHub热榜,分分钟写出万字形式主义大作
一、垃圾文字生成器介绍 最近在浏览GitHub的时候,发现了这样一个骨骼清奇的雷人项目,而且热度还特别高。 项目中文名:狗屁不通文章生成器 项目英文名:BullshitGenerator 根据作者的介绍,他是偶尔需要一些中文文字用于GUI开发时测试文本渲染,因此开发了这个废话生成器。但由于生成的废话实在是太过富于哲理,所以最近已经被小伙伴们给玩坏了。 他的文风可能是这样的: 你发现,...
程序员:我终于知道post和get的区别
是一个老生常谈的话题,然而随着不断的学习,对于以前的认识有很多误区,所以还是需要不断地总结的,学而时习之,不亦说乎
《程序人生》系列-这个程序员只用了20行代码就拿了冠军
你知道的越多,你不知道的越多 点赞再看,养成习惯GitHub上已经开源https://github.com/JavaFamily,有一线大厂面试点脑图,欢迎Star和完善 前言 这一期不算《吊打面试官》系列的,所有没前言我直接开始。 絮叨 本来应该是没有这期的,看过我上期的小伙伴应该是知道的嘛,双十一比较忙嘛,要值班又要去帮忙拍摄年会的视频素材,还得搞个程序员一天的Vlog,还要写BU...
加快推动区块链技术和产业创新发展,2019可信区块链峰会在京召开
11月8日,由中国信息通信研究院、中国通信标准化协会、中国互联网协会、可信区块链推进计划联合主办,科技行者协办的2019可信区块链峰会将在北京悠唐皇冠假日酒店开幕。   区块链技术被认为是继蒸汽机、电力、互联网之后,下一代颠覆性的核心技术。如果说蒸汽机释放了人类的生产力,电力解决了人类基本的生活需求,互联网彻底改变了信息传递的方式,区块链作为构造信任的技术有重要的价值。   1...
Java世界最常用的工具类库
Apache Commons Apache Commons有很多子项目 Google Guava 参考博客
相关热词 c# 二进制截断字符串 c#实现窗体设计器 c#检测是否为微信 c# plc s1200 c#里氏转换原则 c# 主界面 c# do loop c#存为组套 模板 c# 停掉协程 c# rgb 读取图片
立即提问

相似问题