Android studio JDBC

Android studio JDBC 数据库连接开发。。。。。。Android studio JDBC

1个回答

java用jdbc链接数据库,android 很少用这种方式,很不安全,。一般都是android 端 发送请求到后台,后台链接数据库,然后将数据返回到android 端

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
其他相关推荐
在Android Studio使用jdbc连接MySQL遇到java.lang.ExceptionInInitializerError
使用jdbc的方法在安卓项目中连接MySQL数据库,在getConnection()时出现java.lang.ExceptionInInitializerError,实在不懂错在哪了... ![图片说明](https://img-ask.csdn.net/upload/201910/21/1571662749_861983.png)
Android studio开发 登录实例
Android studio通过 jdbc方式连接MySQL,然后如何验证登录,纠结了一天了跪求各位大神帮帮忙,一名初学者![图片说明](http://forum.csdn.net/PointForum/ui/scripts/csdn/Plugin/001/face/1.gif)![图片说明](http://forum.csdn.net/PointForum/ui/scripts/csdn/Plugin/001/face/1.gif)
android通过jdbc连接数据库问题
需要通过jdbc连接访问数据库,目前我是通过需要访问数据库的时候建立于数据库的连接,得到需要的结果后就断开与数据库的连接。但是由于工作需要,现在需要android应用程序在登陆界面输入账号密码后就持续连接数据库,只有当app退出后才会断开与数据库的连接,请问是否可行,该如何操作,望大神指点一二,感激不尽!
在Android Studio中,用jdbc连接MySQL连不上
网上的很多方法都试过,还是不行,各位大神帮我看下什么原因。 目前排除的原因: 1.在单元测试中可以连接成功,并获得数据。所以数据库、连接格式应该没问题。 2.connect-java包试了好几个版本都不行。 3.在Activity中连接不上,但我已经放在新的线程中了,而且用好几种开启新线程的方式试过。 以下是代码 ``` public class MainActivity extends AppCompatActivity { private Connection conn; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); new Thread(){ @Override public void run() { try { Class.forName("com.mysql.jdbc.Driver"); conn = DriverManager.getConnection("jdbc:mysql://rm-bp1p408m8ey1z7ndv4o.mysql.rds.aliyuncs.com/mysql_data", "myroot", "Kwkx12345678"); System.err.println(conn); } catch (ClassNotFoundException e) { e.printStackTrace(); } catch (SQLException e) { e.printStackTrace(); } } }.start(); } } ``` Locat输出: ![图片说明](https://img-ask.csdn.net/upload/201811/28/1543372019_611452.png) 错误提示,百度上搜了一下也没有 Caused by: java.lang.ClassNotFoundException: Didn't find class "java.sql.SQLType" on path: DexPathList[[zip file "/data/app/com.example.administrator.
Android Studio 升级到3.5的错误
Android Studio 弹出升级的消息框,手贱点了一下 ,然后升级到了Android Studio3.5,升级完成后打开Android Studio ,提示升级失败,查看错误为: java.lang.UnsatisfiedLinkError: org.sqlite.core.NativeDB._open_utf8([BI)V at org.sqlite.core.NativeDB._open_utf8(Native Method) at org.sqlite.core.NativeDB._open(NativeDB.java:71) at org.sqlite.core.DB.open(DB.java:174) at org.sqlite.core.CoreConnection.open(CoreConnection.java:220) at org.sqlite.core.CoreConnection.<init>(CoreConnection.java:76) at org.sqlite.jdbc3.JDBC3Connection.<init>(JDBC3Connection.java:25) at org.sqlite.jdbc4.JDBC4Connection.<init>(JDBC4Connection.java:24) at org.sqlite.SQLiteConnection.<init>(SQLiteConnection.java:45) at org.sqlite.JDBC.createConnection(JDBC.java:114) at org.sqlite.JDBC.connect(JDBC.java:88) at java.sql.DriverManager.getConnection(DriverManager.java:664) at java.sql.DriverManager.getConnection(DriverManager.java:270) at com.android.tools.deployer.SqlApkFileDatabase.<init>(SqlApkFileDatabase.java:62) at com.android.tools.deployer.SqlApkFileDatabase.<init>(SqlApkFileDatabase.java:50) at com.android.tools.idea.run.DeploymentService.<init>(DeploymentService.java:56) at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) at java.lang.reflect.Constructor.newInstance(Constructor.java:423) at org.picocontainer.defaults.InstantiatingComponentAdapter.newInstance(InstantiatingComponentAdapter.java:193) at com.intellij.util.pico.CachingConstructorInjectionComponentAdapter.doGetComponentInstance(CachingConstructorInjectionComponentAdapter.java:92) at com.intellij.util.pico.CachingConstructorInjectionComponentAdapter.instantiateGuarded(CachingConstructorInjectionComponentAdapter.java:66) at com.intellij.util.pico.CachingConstructorInjectionComponentAdapter.getComponentInstance(CachingConstructorInjectionComponentAdapter.java:48) at com.intellij.openapi.components.impl.ServiceManagerImpl$MyComponentAdapter.createAndInitialize(ServiceManagerImpl.java:222) at com.intellij.openapi.components.impl.ServiceManagerImpl$MyComponentAdapter.lambda$getComponentInstance$0(ServiceManagerImpl.java:209) at com.intellij.openapi.components.impl.ServiceManagerImpl$MyComponentAdapter.getComponentInstance(ServiceManagerImpl.java:213) at com.intellij.util.pico.DefaultPicoContainer.getLocalInstance(DefaultPicoContainer.java:246) at com.intellij.util.pico.DefaultPicoContainer.getComponentInstance(DefaultPicoContainer.java:213) at com.intellij.openapi.components.ServiceManager.doGetService(ServiceManager.java:52) at com.intellij.openapi.components.ServiceManager.getService(ServiceManager.java:30) at com.android.tools.idea.run.DeploymentService.getInstance(DeploymentService.java:48) at com.android.tools.idea.deploy.DeployActionsInitializer.updateDeployableProvider(DeployActionsInitializer.java:184) at com.android.tools.idea.deploy.DeployActionsInitializer.access$000(DeployActionsInitializer.java:56) at com.android.tools.idea.deploy.DeployActionsInitializer$1.projectOpened(DeployActionsInitializer.java:123) 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.intellij.util.messages.impl.MessageBusConnectionImpl.deliverMessage(MessageBusConnectionImpl.java:114) at com.intellij.util.messages.impl.MessageBusImpl.doPumpMessages(MessageBusImpl.java:393) at com.intellij.util.messages.impl.MessageBusImpl.pumpWaitingBuses(MessageBusImpl.java:354) at com.intellij.util.messages.impl.MessageBusImpl.pumpMessages(MessageBusImpl.java:343) at com.intellij.util.messages.impl.MessageBusImpl.sendMessage(MessageBusImpl.java:320) at com.intellij.util.messages.impl.MessageBusImpl.access$100(MessageBusImpl.java:29) at com.intellij.util.messages.impl.MessageBusImpl$1.invoke(MessageBusImpl.java:192) at com.sun.proxy.$Proxy17.projectOpened(Unknown Source) at com.intellij.openapi.project.impl.ProjectManagerImpl.fireProjectOpened(ProjectManagerImpl.java:780) at com.intellij.openapi.project.impl.ProjectManagerImpl.lambda$null$6(ProjectManagerImpl.java:401) at com.intellij.openapi.application.TransactionGuardImpl.lambda$submitTransactionAndWait$2(TransactionGuardImpl.java:165) at com.intellij.openapi.application.TransactionGuardImpl.runSyncTransaction(TransactionGuardImpl.java:88) at com.intellij.openapi.application.TransactionGuardImpl.lambda$submitTransaction$1(TransactionGuardImpl.java:111) at com.intellij.openapi.application.impl.LaterInvocator$FlushQueue.doRun(LaterInvocator.java:435) at com.intellij.openapi.application.impl.LaterInvocator$FlushQueue.runNextEvent(LaterInvocator.java:419) at com.intellij.openapi.application.impl.LaterInvocator$FlushQueue.run(LaterInvocator.java:403) at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:311) at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:764) at java.awt.EventQueue.access$500(EventQueue.java:98) at java.awt.EventQueue$3.run(EventQueue.java:715) at java.awt.EventQueue$3.run(EventQueue.java:709) at java.security.AccessController.doPrivileged(Native Method) at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:74) at java.awt.EventQueue.dispatchEvent(EventQueue.java:734) at com.intellij.ide.IdeEventQueue.defaultDispatchEvent(IdeEventQueue.java:757) at com.intellij.ide.IdeEventQueue._dispatchEvent(IdeEventQueue.java:706) at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.java:375) at com.intellij.ide.IdeEventQueue.pumpEventsForHierarchy(IdeEventQueue.java:814) at com.intellij.openapi.progress.util.ProgressWindow.startBlocking(ProgressWindow.java:210) at com.intellij.openapi.progress.util.ProgressWindow.startBlocking(ProgressWindow.java:196) at com.intellij.openapi.application.impl.ApplicationImpl.runProcessWithProgressSynchronously(ApplicationImpl.java:609) at com.intellij.openapi.progress.impl.CoreProgressManager.runProcessWithProgressSynchronously(CoreProgressManager.java:454) at com.intellij.openapi.progress.impl.ProgressManagerImpl.runProcessWithProgressSynchronously(ProgressManagerImpl.java:109) at com.intellij.openapi.progress.impl.CoreProgressManager.runProcessWithProgressSynchronously(CoreProgressManager.java:251) at com.intellij.openapi.progress.impl.CoreProgressManager.runProcessWithProgressSynchronously(CoreProgressManager.java:205) at com.intellij.openapi.project.impl.ProjectManagerImpl.loadProjectUnderProgress(ProjectManagerImpl.java:450) at com.intellij.openapi.project.impl.ProjectManagerImpl.openProject(ProjectManagerImpl.java:425) at com.intellij.platform.PlatformProjectOpenProcessor.doOpenProject(PlatformProjectOpenProcessor.java:260) at com.intellij.ide.RecentProjectsManagerBase.doOpenProject(RecentProjectsManagerBase.java:512) at com.intellij.ide.RecentProjectsManagerBase.doReopenLastProject(RecentProjectsManagerBase.java:634) at com.intellij.ide.RecentProjectsManagerBase$MyAppLifecycleListener.appStarting(RecentProjectsManagerBase.java:692) 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.intellij.util.messages.impl.MessageBusConnectionImpl.deliverMessage(MessageBusConnectionImpl.java:114) at com.intellij.util.messages.impl.MessageBusImpl.doPumpMessages(MessageBusImpl.java:393) at com.intellij.util.messages.impl.MessageBusImpl.pumpWaitingBuses(MessageBusImpl.java:354) at com.intellij.util.messages.impl.MessageBusImpl.pumpMessages(MessageBusImpl.java:343) at com.intellij.util.messages.impl.MessageBusImpl.sendMessage(MessageBusImpl.java:320) at com.intellij.util.messages.impl.MessageBusImpl.access$100(MessageBusImpl.java:29) at com.intellij.util.messages.impl.MessageBusImpl$1.invoke(MessageBusImpl.java:192) at com.sun.proxy.$Proxy63.appStarting(Unknown Source) at com.intellij.idea.IdeaApplication$IdeStarter.lambda$main$1(IdeaApplication.java:388) at com.intellij.openapi.application.TransactionGuardImpl.runSyncTransaction(TransactionGuardImpl.java:88) at com.intellij.openapi.application.TransactionGuardImpl.lambda$submitTransaction$1(TransactionGuardImpl.java:111) at com.intellij.openapi.application.TransactionGuardImpl.submitTransaction(TransactionGuardImpl.java:120) at com.intellij.openapi.application.TransactionGuard.submitTransaction(TransactionGuard.java:121) at com.intellij.idea.IdeaApplication$IdeStarter.main(IdeaApplication.java:386) at com.intellij.idea.IdeaApplication.lambda$run$1(IdeaApplication.java:220) at com.intellij.openapi.application.TransactionGuardImpl.performUserActivity(TransactionGuardImpl.java:195) at com.intellij.idea.IdeaApplication.run(IdeaApplication.java:220) at com.intellij.idea.IdeaApplication.lambda$initApplication$0(IdeaApplication.java:77) at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:311) at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:764) at java.awt.EventQueue.access$500(EventQueue.java:98) at java.awt.EventQueue$3.run(EventQueue.java:715) at java.awt.EventQueue$3.run(EventQueue.java:709) at java.security.AccessController.doPrivileged(Native Method) at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:74) at java.awt.EventQueue.dispatchEvent(EventQueue.java:734) at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.java:349) at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:205) at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116) at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93) at java.awt.EventDispatchThread.run(EventDispatchThread.java:82) 操作系统是Win10 专业版 64位。 以为是我的老版本导致的程序不对,然后把和Android Studio有关的文件都删了,重新安装,安装好了以后可以用了,但是关了AS,再重新打开AS,又开始报上面的错误,有没有遇到这个问题的?如何来解决这个问题? ------------------------------------------------------------》》》》》 很白痴的问题,以及个人的习惯导致的,使用管理员权限打开就好了,AS会在AppData/Local 中创建一个临时的sqlite 数据访问的dll,不是管理员权限访问不了,就导致了这个错误。
Android studio访问mysql闪退,本地测试可以
使用为mysql-connector-java-8.0.16.jar以及mysql8.0.19 在本地测试通过 public class DBUtils { private static String driver = "com.mysql.cj.jdbc.Driver";//MySQL 驱动 private static String url = "jdbc:mysql://192.168.2.146:3306/helper?useSSL=false&serverTimezone=UTC&allowPublicKeyRetrieval=true";//MYSQL数据库连接Url private static String user = "wang";//用户名 private static String password = "Imissyou**";//密码 private static Connection getConnection() { Connection conn = null; try { Class.forName(driver); // conn = DriverManager.getConnection(url,user,password); } catch (SQLException ex) { ex.printStackTrace(); } catch (ClassNotFoundException ex) { ex.printStackTrace(); } return conn; } public static Map<String, String> login(User user) { HashMap<String, String> map = new HashMap<>(); Connection conn = getConnection(); try { Statement st = conn.createStatement(); String sql= "select * from user where username ='" + user.getUsername() + "' and password ='" + user.getPassword() + "'"; ResultSet res = st.executeQuery(sql); if (res == null) { return null; } else { int cnt = res.getMetaData().getColumnCount(); res.next(); for (int i = 1; i <= cnt; ++i) { String field = res.getMetaData().getColumnName(i); map.put(field, res.getString(field)); } conn.close(); st.close(); res.close(); return map; } } catch (Exception e) { e.printStackTrace(); return null; } } public static void main(String []args){ User user = new User("aaa","123456"); Map<String,String> result= DBUtils.login(user); System.out.println(result); } } 但是在主界面绑定事件,访问数据库时直接闪退并报错 ![图片说明](https://img-ask.csdn.net/upload/202003/15/1584252548_20385.jpg) 主界面代码如下: package com.example.helper; import androidx.appcompat.app.AppCompatActivity; import android.content.Context; import android.content.Intent; import android.os.Bundle; import android.os.StrictMode; import android.text.TextUtils; import android.view.View; import android.widget.Button; import android.widget.EditText; import android.widget.TextView; import android.widget.Toast; import java.util.Map; public class MainActivity extends AppCompatActivity { private Button register; private Button login_user; private TextView forget_password; private TextView login_visitor; private EditText et_username; private EditText et_password; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); //初始化控件 init(); //注册界面跳转 register.setOnClickListener(new View.OnClickListener(){ @Override public void onClick(View v){ Intent intent = new Intent(MainActivity.this, RegisterActivity.class); startActivity(intent); } }); //登录功能未加载,等待后台数据库完善 login_user.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { String username = et_username.getText().toString(); //获取用户名 String password = et_password.getText().toString(); //获取密码 if(TextUtils.isEmpty(username)){ Toast.makeText(MainActivity.this,"请输入用户名",Toast.LENGTH_SHORT).show(); } else if(TextUtils.isEmpty(password)){ Toast.makeText(MainActivity.this,"请输入密码",Toast.LENGTH_SHORT).show(); } //本地管理员帐号 else if(username.equals("admin")&&password.equals("admin")){ Intent intent = new Intent(MainActivity.this,HomePageActivity.class); startActivity(intent); } //else Toast.makeText(MainActivity.this,"未连接后台数据库",Toast.LENGTH_SHORT).show(); else{ User user = new User(username,password); checkLogin(user); //Toast.makeText(MainActivity.this,"已获取"+username+" "+password,Toast.LENGTH_SHORT).show(); } } }); //首页跳转 login_visitor.setOnClickListener(new View.OnClickListener(){ @Override public void onClick(View v){ Intent intent = new Intent(MainActivity.this, HomePageActivity.class); startActivity(intent); } }); //找回密码界面跳转 forget_password.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { Intent intent = new Intent(MainActivity.this,ForgetPasswordActivity.class); startActivity(intent); } }); } private void init() { et_username = findViewById(R.id.et_username); et_password = findViewById(R.id.et_password); register = findViewById(R.id.btn_2); login_user = findViewById(R.id.btn_1); login_visitor = findViewById(R.id.login_visitor); forget_password = findViewById(R.id.forget_password); } class DBThread implements Runnable { private User user; private Context context; public void setUser(User user) { this.user = user; } public void setContext(Context context) { this.context = context; } @Override public void run() { Map<String,String> result= DBUtils.login(user); /* if (result != null && result.size() > 0) { Intent intent = new Intent(MainActivity.this,HomePageActivity.class); Toast.makeText(MainActivity.this,"有此帐号",Toast.LENGTH_SHORT).show(); startActivity(intent); } */ } } private void checkLogin(User u) { DBThread dt = new DBThread(); dt.setUser(u); dt.setContext(MainActivity.this); Thread thread = new Thread(dt); thread.start(); } }
android studio连接mysql数据库报错,请问这是那里的问题?
我用android studio 连接mysql数据库,用的是从maven上下载的JDBC包。但是点击运行后它提示: AGPBI: {"kind":"error","text":"Default interface methods are only supported starting with Android N (--min-api 24): com.mysql.cj.protocol.Message com.mysql.cj.interceptors.QueryInterceptor.postProcess(com.mysql.cj.protocol.Message, com.mysql.cj.protocol.Message)","sources":[{}],"tool":"D8"} FAILURE: Build failed with an exception. * What went wrong: Execution failed for task ':app:mergeExtDexDebug'. > Could not resolve all files for configuration ':app:debugRuntimeClasspath'. > Failed to transform file 'mysql-connector-java-8.0.11.jar' to match attributes {artifactType=android-dex, dexing-is-debuggable=true, dexing-min-sdk=15, org.gradle.usage=java-runtime-jars} > Execution failed for DexingTransform: D:\Anzhuo-SDK\android project\app\libs\mysql-connector-java-8.0.11.jar. > Error while dexing. > Failed to transform file 'mysql-connector-java-8.0.11.jar' to match attributes {artifactType=android-dex, dexing-is-debuggable=true, dexing-min-sdk=15, org.gradle.usage=java-runtime-jars} > Execution failed for DexingTransform: D:\Anzhuo-SDK\android project\app\libs\mysql-connector-java-8.0.11.jar. > Error while dexing. * Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights. * Get more help at https://help.gradle.org Deprecated Gradle features were used in this build, making it incompatible with Gradle 6.0. Use '--warning-mode all' to show the individual deprecation warnings. See https://docs.gradle.org/5.1.1/userguide/command_line_interface.html#sec:command_line_warnings BUILD FAILED in 19s 我想问一下,这是为什么?是因为JAR的版本问题吗?
android studio 关于jar包问题 不知道怎么解决
apply plugin: 'com.android.application' apply plugin: 'com.jakewharton.butterknife' android { compileSdkVersion 25 buildToolsVersion "25.0.0" useLibrary 'org.apache.http.legacy' defaultConfig { applicationId "com.mynj" minSdkVersion 16 targetSdkVersion 25 versionCode 1 versionName "1.0" } buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } } sourceSets { main { assets.srcDirs = ['src/main/assets', 'src/main/assets/'] } } } dependencies { compile fileTree(include: ['*.jar'], dir: 'libs') androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', { exclude group: 'com.android.support', module: 'support-annotations' }) testCompile 'junit:junit:4.12' compile 'com.android.support:appcompat-v7:25.0.1' compile 'com.android.support:recyclerview-v7:25.0.1' compile 'io.reactivex.rxjava2:rxjava:2.1.2' compile 'io.reactivex.rxjava2:rxandroid:2.0.1' compile 'com.squareup.retrofit2:retrofit:2.3.0' compile 'com.squareup.retrofit2:converter-gson:2.3.0' compile 'com.jakewharton.retrofit:retrofit2-rxjava2-adapter:1.0.0' compile 'com.squareup.okhttp3:okhttp:3.8.1' compile 'com.squareup.okhttp3:logging-interceptor:3.8.1' compile 'com.jakewharton:butterknife:8.4.0' annotationProcessor 'com.jakewharton:butterknife-compiler:8.4.0' compile 'com.squareup.picasso:picasso:2.5.1' compile 'com.github.bumptech.glide:glide:3.5.2' } 运行之后报错 Gradle build finished with 186 error(s) in 1m 39s 514ms Error:warning: Ignoring InnerClasses attribute for an anonymous inner class Error:(com.mysql.jdbc.ConnectionImpl$1) that doesn't come with an Error:associated EnclosingMethod attribute. This class was probably produced by a Error:compiler that did not target the modern .class file format. The recommended Error:solution is to recompile the class from source, using an up-to-date compiler Error:and without specifying any "-target" type options. The consequence of ignoring Error:this warning is that reflective operations on this class will incorrectly Error:indicate that it is *not* an inner class. Error:(com.mysql.jdbc.ConnectionImpl$10) that doesn't come with an Error:warning: Ignoring InnerClasses attribute for an anonymous inner class Error:associated EnclosingMethod attribute. This class was probably produced by a Error:compiler that did not target the modern .class file format. The recommended Error:solution is to recompile the class from source, using an up-to-date compiler Error:and without specifying any "-target" type options. The consequence of ignoring Error:this warning is that reflective operations on this class will incorrectly Error:warning: Ignoring InnerClasses attribute for an anonymous inner class Error:indicate that it is *not* an inner class. Error:(com.mysql.jdbc.ConnectionImpl$2) that doesn't come with an Error:associated EnclosingMethod attribute. This class was probably produced by a Error:compiler that did not target the modern .class file format. The recommended Error:solution is to recompile the class from source, using an up-to-date compiler Error:and without specifying any "-target" type options. The consequence of ignoring Error:this warning is that reflective operations on this class will incorrectly Error:indicate that it is *not* an inner class. Error:(com.mysql.jdbc.ConnectionImpl$3) that doesn't come with an Error:warning: Ignoring InnerClasses attribute for an anonymous inner class Error:associated EnclosingMethod attribute. This class was probably produced by a Error:compiler that did not target the modern .class file format. The recommended Error:solution is to recompile the class from source, using an up-to-date compiler Error:and without specifying any "-target" type options. The consequence of ignoring Error:this warning is that reflective operations on this class will incorrectly Error:indicate that it is *not* an inner class.
Android studio 连接数据库问题 我这样写有错吗帮我看看
package com.example.administrator.testdate; import android.os.Bundle; import android.os.StrictMode; import android.support.design.widget.FloatingActionButton; import android.support.design.widget.Snackbar; import android.support.v7.app.AppCompatActivity; import android.support.v7.widget.Toolbar; import android.view.Menu; import android.view.MenuItem; import android.view.View; import android.widget.Button; import android.widget.EditText; import java.sql.Connection; import java.sql.DriverManager; import java.sql.PreparedStatement; import java.sql.Statement; public class MainActivity extends AppCompatActivity { String Username="root"; //数据库用户名 String Password="12345678"; //数据库用户密码 Button button1; Button button2; EditText textView1; EditText textView2; Connection conn=null; Statement stmt=null; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar); button1 = (Button) findViewById(R.id.button1); button2 = (Button) findViewById(R.id.button2); textView1=(EditText)findViewById(R.id.editText2); textView2=(EditText)findViewById(R.id.editText) ; StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder().detectDiskReads().detectDiskWrites().detectNetwork().penaltyLog().build()); StrictMode.setVmPolicy(new StrictMode.VmPolicy.Builder().detectLeakedSqlLiteObjects().detectLeakedClosableObjects().penaltyLog().penaltyDeath().build()); FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab); fab.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG) .setAction("Action", null).show(); } }); button1.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { connection(); } }); button2.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { textView1.setText(""); textView2.setText(""); } }); } @Override public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bar if it is present. getMenuInflater().inflate(R.menu.menu_main, menu); return true; } @Override public boolean onOptionsItemSelected(MenuItem item) { // Handle action bar item clicks here. The action bar will // automatically handle clicks on the Home/Up button, so long // as you specify a parent activity in AndroidManifest.xml. int id = item.getItemId(); //noinspection SimplifiableIfStatement if (id == R.id.action_settings) { return true; } return super.onOptionsItemSelected(item); } public void connection() { String username = textView1.getText().toString(); String password=textView2.getText().toString(); if (username != null) { //打开数据库 try {//注册驱动程序 Class.forName("com.mysql.jdbc.Driver"); } catch (java.lang.ClassNotFoundException e) { System.err.println("Driver Error " + e.getMessage()); } //连接数据库并创建Statement 对象 String sConnStr = "jdbc:mysql://localhost/testdate?user=" + Username + "&password=" + Password + "&useUnicode=true&characterEncoding=utf8"; try { conn = DriverManager.getConnection(sConnStr); conn.setAutoCommit(true); //更新数据库 String sql = "insert into testdate(username,password) values(?,?)"; PreparedStatement sta = conn.prepareStatement(sql); sta.setString(1, username); sta.setString(2, password); sta.executeUpdate(); sta.close(); conn.close(); } catch (Exception e) { System.err.println("数据库连接错误: " + e.getMessage()); return; } } } }
安卓开发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. ``` 在网上百度了很多方法都没有解决,起初以为是驱动的问题,但是换了一个仍然不好用,求求大神赐教
求指教 android mysql更新问题
环境 Android 6.0 Android studio Xampp Mysql连接方式JDBC 数据在更新的时候,不管数据库里面含不含有想修改的数据 按下在库移动的按钮之后都会提示”移动完了“ 如何加一个验证的过程,如没有符合的Hinban和Tanaban1则提示输入错误 求指教 代码如下 ``` protected String doInBackground(String... strings) { try{ Class.forName("com.mysql.jdbc.Driver"); Connection conn= DriverManager.getConnection(url,user,pass); if (conn==null){ msg="接続エラー"; Toast.makeText(getApplicationContext(),msg, Toast.LENGTH_LONG).show(); } else { String query="UPDATE snk_io SET Tanaban='"+Tanaban2+"' WHERE Hinban='"+Hinban+"' and Tanaban='"+Tanaban1+"'"; Statement stmt = conn.createStatement(); stmt.executeUpdate(query); msg="移動完了です!!"; } conn.close(); } catch (Exception e) { msg="エラー発生しました。"; e.printStackTrace(); } return msg; } @Override protected void onPostExecute(String msg){ textView.setText(msg); ET1.setText(""); ET2.setText(""); ET3.setText(""); //Toast.makeText(getApplicationContext(),"入力しました", Toast.LENGTH_SHORT).show(); } ```
android APP连接mysql时,APP闪退
安卓程序连接MySQL一直不成功,本地连接可以。我是用手机调试的,点击接mysql按钮时,APP闪退。在网上找了好多方法都不行。求看看什么问题 错误日志如下: 2019-08-25 08:25:33.377 5570-5570/mark.zhang E/AndroidRuntime: FATAL EXCEPTION: main Process: mark.zhang, PID: 5570 java.lang.IllegalStateException: Could not execute method for android:onClick at android.view.View$DeclaredOnClickListener.onClick(View.java:5692) at android.view.View.performClick(View.java:6663) at android.view.View.performClickInternal(View.java:6635) at android.view.View.access$3100(View.java:794) at android.view.View$PerformClick.run(View.java:26199) at android.os.Handler.handleCallback(Handler.java:907) at android.os.Handler.dispatchMessage(Handler.java:105) at android.os.Looper.loop(Looper.java:216) at android.app.ActivityThread.main(ActivityThread.java:7625) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:524) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:987) Caused by: java.lang.reflect.InvocationTargetException at java.lang.reflect.Method.invoke(Native Method) at android.view.View$DeclaredOnClickListener.onClick(View.java:5687) at android.view.View.performClick(View.java:6663)  at android.view.View.performClickInternal(View.java:6635)  at android.view.View.access$3100(View.java:794)  at android.view.View$PerformClick.run(View.java:26199)  at android.os.Handler.handleCallback(Handler.java:907)  at android.os.Handler.dispatchMessage(Handler.java:105)  at android.os.Looper.loop(Looper.java:216)  at android.app.ActivityThread.main(ActivityThread.java:7625)  at java.lang.reflect.Method.invoke(Native Method)  at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:524)  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:987)  Caused by: java.lang.BootstrapMethodError: Exception from call site #39 bootstrap method at com.mysql.cj.jdbc.AbandonedConnectionCleanupThread.<clinit>(AbandonedConnectionCleanupThread.java:58) at java.lang.Class.classForName(Native Method) at java.lang.Class.forName(Class.java:453) at java.lang.Class.forName(Class.java:378) at com.mysql.cj.jdbc.NonRegisteringDriver.<clinit>(NonRegisteringDriver.java:99) at java.lang.Class.classForName(Native Method) at java.lang.Class.forName(Class.java:453) at java.lang.Class.forName(Class.java:378) at mark.zhang.Util.openConnection(Util.java:16) at mark.zhang.Main.onConn(Main.java:30) at java.lang.reflect.Method.invoke(Native Method)  at android.view.View$DeclaredOnClickListener.onClick(View.java:5687)  at android.view.View.performClick(View.java:6663)  at android.view.View.performClickInternal(View.java:6635)  at android.view.View.access$3100(View.java:794)  at android.view.View$PerformClick.run(View.java:26199)  at android.os.Handler.handleCallback(Handler.java:907)  at android.os.Handler.dispatchMessage(Handler.java:105)  at android.os.Looper.loop(Looper.java:216)  at android.app.ActivityThread.main(ActivityThread.java:7625)  at java.lang.reflect.Method.invoke(Native Method)  at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:524)  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:987)  Caused by: java.lang.ClassCastException: Bootstrap method returned null at com.mysql.cj.jdbc.AbandonedConnectionCleanupThread.<clinit>(AbandonedConnectionCleanupThread.java:58)  at java.lang.Class.classForName(Native Method)  at java.lang.Class.forName(Class.java:453)  at java.lang.Class.forName(Class.java:378)  at com.mysql.cj.jdbc.NonRegisteringDriver.<clinit>(NonRegisteringDriver.java:99)  at java.lang.Class.classForName(Native Method)  at java.lang.Class.forName(Class.java:453)  at java.lang.Class.forName(Class.java:378)  at mark.zhang.Util.openConnection(Util.java:16)  at mark.zhang.Main.onConn(Main.java:30)  at java.lang.reflect.Method.invoke(Native Method)  at android.view.View$DeclaredOnClickListener.onClick(View.java:5687)  at android.view.View.performClick(View.java:6663)  at android.view.View.performClickInternal(View.java:6635)  at android.view.View.access$3100(View.java:794)  at android.view.View$PerformClick.run(View.java:26199)  at android.os.Handler.handleCallback(Handler.java:907)  at android.os.Handler.dispatchMessage(Handler.java:105)  at android.os.Looper.loop(Looper.java:216)  at android.app.ActivityThread.main(ActivityThread.java:7625)  at java.lang.reflect.Method.invoke(Native Method)  at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:524)  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:987)  2019-08-25 08:25:33.398 5570-5570/mark.zhang I/Process: Sending signal. PID: 5570 SIG: 9 源码如下: 这是util.java ``` package mark.zhang; import java.sql.Connection; import java.sql.DriverManager; import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Statement; public class Util { public static Connection openConnection(String url, String user, String password) { Connection conn = null; try { final String DRIVER_NAME = "com.mysql.cj.jdbc.Driver"; Class.forName(DRIVER_NAME); conn = DriverManager.getConnection(url, user, password); } catch (ClassNotFoundException e) { conn = null; } catch (SQLException e) { conn = null; } return conn; } public static void query(Connection conn, String sql) { if (conn == null) { return; } Statement statement = null; ResultSet result = null; try { statement = conn.createStatement(); result = statement.executeQuery(sql); if (result != null && result.first()) { int idColumnIndex = result.findColumn("id"); int nameColumnIndex = result.findColumn("name"); System.out.println("id\t\t" + "name"); while (!result.isAfterLast()) { System.out.print(result.getString(idColumnIndex) + "\t\t"); System.out.println(result.getString(nameColumnIndex)); result.next(); } } } catch (SQLException e) { e.printStackTrace(); } finally { try { if (result != null) { result.close(); result = null; } if (statement != null) { statement.close(); statement = null; } } catch (SQLException sqle) { } } } public static boolean execSQL(Connection conn, String sql) { boolean execResult = false; if (conn == null) { return execResult; } Statement statement = null; try { statement = conn.createStatement(); if (statement != null) { execResult = statement.execute(sql); } } catch (SQLException e) { execResult = false; } return execResult; } } ``` 这是main.java ``` package mark.zhang; import com.mysql.cj.jdbc.AbandonedConnectionCleanupThread; import java.sql.Connection; import java.sql.SQLException; import androidx.appcompat.app.AppCompatActivity; import android.app.Activity; import android.os.Bundle; import android.view.View; import java.sql.Connection; import java.sql.DriverManager; import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Statement; public class Main extends Activity { private static final String REMOTE_IP = "223.104.64.237"; private static final String URL = "jdbc:mysql://223.104.64.237:3306/mydb?useSSL=false&serverTimezone=GMT&characterEncoding=utf-8&autoReconnect=true"; private static final String USER = "root"; private static final String PASSWORD = "123"; private Connection conn; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); } public void onConn(View view) { conn = Util.openConnection(URL, USER, PASSWORD); /* final Thread thread = new Thread(new Runnable() { @Override public void run() { // 反复尝试连接,直到连接成功后退出循环 while (!Thread.interrupted()) { try { Thread.sleep(100); // 每隔0.1秒尝试连接 } catch (InterruptedException e) { System.out.println("链接数据库"); } // 2.设置好IP/端口/数据库名/用户名/密码等必要的连接信息 String url="jdbc:mysql://223.104.64.237:3306/mydb?useSSL=false&serverTimezone=Hongkong&characterEncoding=utf-8&autoReconnect=true"; String user = "root"; String password = "123"; // 3.连接JDBC try { Class.forName("com.mysql.cj.jdbc.Driver"); Connection conn = DriverManager.getConnection(url,user,password); System.out.println("远程连接成功!"); conn.close(); return; } catch (SQLException e) { System.out.println("远程连接失败!"); } catch (ClassNotFoundException e){ } } } }); thread.start();*/ } public void onInsert(View view) { String sql = "insert into mytable values(9, 'hanmeimei')"; Util.execSQL(conn, sql); } public void onDelete(View view) { String sql = "delete from mytable where name='mark'"; Util.execSQL(conn, sql); } public void onUpdate(View view) { String sql = "update mytable set name='李磊' where name='韩美'"; Util.execSQL(conn, sql); } public void onQuery(View view) { System.out.println("All users info:"); Util.query(conn, "select * from mytable"); } @Override protected void onDestroy() { super.onDestroy(); if (conn != null) { try { conn.close(); } catch (SQLException e) { conn = null; } finally { conn = null; } } } } ```
链接数据库时存在获取不到值,con为空的情况
错误信息: java.lang.NullPointerException: Attempt to invoke interface method 'java.sql.PreparedStatement java.sql.Connection.prepareStatement(java.lang.String)' on a null object reference at com.example.ruanjian.dao.AdminDao.login(AdminDao.java:18) at com.example.ruanjian.MainActivity$1.onClick(MainActivity.java:49) 主程序代码 ![图片说明](https://img-ask.csdn.net/upload/202003/07/1583573303_393695.png) login代码: ![图片说明](https://img-ask.csdn.net/upload/202003/07/1583573407_762577.png) debug了一遍后,首先是这是整个app运行时的debug,此时con为空 ![图片说明](https://img-ask.csdn.net/upload/202003/08/1583627935_129287.png) 单独运行dbutil时:con有值: ![图片说明](https://img-ask.csdn.net/upload/202003/08/1583628199_793129.png) 那么app运行时和这个函数单独运行时的区别是什么,为什么有时能获取到值有时获取不到? dbutil代码: ``` package com.example.ruanjian.util; import java.sql.Connection; import java.sql.DriverManager; import java.sql.SQLException; public class DbUtil { private String dbUrl="jdbc:mysql://192.168.0.104:3306/db_daily?useUnicode=true&characterEncoding=utf8"; // 数据库连接地址 private String dbUserName="root"; // 用户名 private String dbPassword=""; // 密码 private String jdbcName="com.mysql.jdbc.Driver"; // 驱动名称 /** * 获取数据库连接 * @return * @throws Exception */ public Connection getCon(){ try { Class.forName(jdbcName); } catch (ClassNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } Connection con = null; try { con = DriverManager.getConnection(dbUrl, dbUserName, dbPassword); } catch (SQLException e) { // TODO Auto-generated catch block e.printStackTrace(); } return con; } /** * 关闭数据库连接 * @param con * @throws Exception */ public void closeCon(Connection con)throws Exception{ if(con!=null){ con.close(); } } public static void main(String[] args) { DbUtil dbUtil=new DbUtil(); try { dbUtil.getCon(); System.out.println("数据库连接成功!"); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); System.out.println("数据库连接失败"); } } } ``` basedao代码: ``` package com.example.ruanjian.dao; import android.util.Log; import java.sql.Connection; import java.sql.SQLException; import com.example.ruanjian.util.DbUtil; /** * * @author llq *创建对数据库连接对象,整个项目与数据库打交道都用这一个对象. */ public class BaseDao { public Connection con = new DbUtil().getCon(); public void closeDao(){ try { con.close(); } catch (SQLException e) { // TODO Auto-generated catch block e.printStackTrace(); } } } ```
Android直连MySQL ,无法建立连接
学习用尝试直连mysql5.7 ``` public void run() { Connection cn=null; try { Class.forName("com.mysql.jdbc.Driver"); String url="jdbc:mysql://IP:Port/db"; String user="root"; String password="123456"; cn= DriverManager.getConnection(url,user,password); //程序执行到这一步抛出异常 if(cn!=null) Log.e("ccc","cccc"); String sql="select B_Name from book"; Statement st=(Statement)cn.createStatement(); ResultSet rs=st.executeQuery(sql); while(rs.next()){ String mybook=rs.getString("B_Name"); Log.e("Mainactivity",mybook); } cn.close(); st.close(); rs.close(); } catch (ClassNotFoundException e) { e.printStackTrace(); } catch (SQLException e) { e.printStackTrace(); } } }).start(); ``` ![jar包](https://img-ask.csdn.net/upload/201805/20/1526829805_810045.png) 服务器的MySQL57服务开着, IP、Port、User和Password我都用Navicat测过,有效。排查下来不知道问题可能出在哪里。
androidstudio为啥连不上mysql呀,老报如下错
源码: ``` bt1.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { System.out.println("进入点击事件!!!!!!!!!"); new Thread(new Runnable(){ public void run(){ try { System.out.println("进入线程!!!!!!!!"); System.out.println("开始加载驱动"); Class.forName("com.mysql.jdbc.Driver"); System.out.println("驱动加载完成"); java.sql.Connection cn= DriverManager.getConnection( "jdbc:mysql://192.168.0.106:3306/test","root", "root"); System.out.println("链接数据库"); String sql="select name from androidtest"; Statement st=(Statement)cn.createStatement(); ResultSet rs=st.executeQuery(sql); while(rs.next()){//读表mytable中的每一列 String mybook=rs.getString("name ");//读取的是B_Name这一列,传给mybook Log.i("MainActivity",mybook); } cn.close();//一定要关闭 st.close(); rs.close(); } catch (ClassNotFoundException e) { e.printStackTrace(); } catch (SQLException e) { e.printStackTrace(); } } }).start(); } ``` 报错信息: ``` 2019-08-13 16:04:24.442 29017-29017/com.example.androidmysqltext001 I/System.out: 进入点击事件!!!!!!!!! 2019-08-13 16:04:24.447 29017-29418/com.example.androidmysqltext001 I/System.out: 进入线程!!!!!!!! 2019-08-13 16:04:24.447 29017-29418/com.example.androidmysqltext001 I/System.out: 开始加载驱动 2019-08-13 16:04:24.542 29017-29036/com.example.androidmysqltext001 I/zygote64: Do partial code cache collection, code=30KB, data=21KB 2019-08-13 16:04:24.542 29017-29036/com.example.androidmysqltext001 I/zygote64: After code cache collection, code=26KB, data=20KB 2019-08-13 16:04:24.542 29017-29036/com.example.androidmysqltext001 I/zygote64: Increasing code cache capacity to 128KB 2019-08-13 16:04:24.608 29017-29418/com.example.androidmysqltext001 I/System.out: 驱动加载完成 2019-08-13 16:06:31.922 29017-29418/com.example.androidmysqltext001 W/System.err: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure 2019-08-13 16:06:31.922 29017-29418/com.example.androidmysqltext001 W/System.err: The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server. 2019-08-13 16:06:31.922 29017-29418/com.example.androidmysqltext001 W/System.err: at java.lang.reflect.Constructor.newInstance0(Native Method) 2019-08-13 16:06:31.922 29017-29418/com.example.androidmysqltext001 W/System.err: at java.lang.reflect.Constructor.newInstance(Constructor.java:334) 2019-08-13 16:06:31.922 29017-29418/com.example.androidmysqltext001 W/System.err: at com.mysql.jdbc.Util.handleNewInstance(Util.java:409) 2019-08-13 16:06:31.922 29017-29418/com.example.androidmysqltext001 W/System.err: at com.mysql.jdbc.SQLError.createCommunicationsException(SQLError.java:1127) 2019-08-13 16:06:31.922 29017-29418/com.example.androidmysqltext001 W/System.err: at com.mysql.jdbc.MysqlIO.<init>(MysqlIO.java:356) 2019-08-13 16:06:31.922 29017-29418/com.example.androidmysqltext001 W/System.err: at com.mysql.jdbc.ConnectionImpl.coreConnect(ConnectionImpl.java:2502) 2019-08-13 16:06:31.922 29017-29418/com.example.androidmysqltext001 W/System.err: at com.mysql.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:2539) 2019-08-13 16:06:31.922 29017-29418/com.example.androidmysqltext001 W/System.err: at com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2321) 2019-08-13 16:06:31.922 29017-29418/com.example.androidmysqltext001 W/System.err: at com.mysql.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:832) 2019-08-13 16:06:31.922 29017-29418/com.example.androidmysqltext001 W/System.err: at com.mysql.jdbc.JDBC4Connection.<init>(JDBC4Connection.java:46) 2019-08-13 16:06:31.922 29017-29418/com.example.androidmysqltext001 W/System.err: at java.lang.reflect.Constructor.newInstance0(Native Method) 2019-08-13 16:06:31.922 29017-29418/com.example.androidmysqltext001 W/System.err: at java.lang.reflect.Constructor.newInstance(Constructor.java:334) 2019-08-13 16:06:31.922 29017-29418/com.example.androidmysqltext001 W/System.err: at com.mysql.jdbc.Util.handleNewInstance(Util.java:409) 2019-08-13 16:06:31.922 29017-29418/com.example.androidmysqltext001 W/System.err: at com.mysql.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:417) 2019-08-13 16:06:31.922 29017-29418/com.example.androidmysqltext001 W/System.err: at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:344) 2019-08-13 16:06:31.922 29017-29418/com.example.androidmysqltext001 W/System.err: at java.sql.DriverManager.getConnection(DriverManager.java:569) 2019-08-13 16:06:31.922 29017-29418/com.example.androidmysqltext001 W/System.err: at java.sql.DriverManager.getConnection(DriverManager.java:219) 2019-08-13 16:06:31.922 29017-29418/com.example.androidmysqltext001 W/System.err: at com.example.androidmysqltext001.MainActivity$1$1.run(MainActivity.java:33) 2019-08-13 16:06:31.923 29017-29418/com.example.androidmysqltext001 W/System.err: at java.lang.Thread.run(Thread.java:784) 2019-08-13 16:06:31.923 29017-29418/com.example.androidmysqltext001 W/System.err: Caused by: java.net.ConnectException: failed to connect to /192.168.0.106 (port 3306) from /:: (port 51602): connect failed: ETIMEDOUT (Connection timed out) 2019-08-13 16:06:31.923 29017-29418/com.example.androidmysqltext001 W/System.err: at libcore.io.IoBridge.connect(IoBridge.java:138) 2019-08-13 16:06:31.923 29017-29418/com.example.androidmysqltext001 W/System.err: at java.net.PlainSocketImpl.socketConnect(PlainSocketImpl.java:129) 2019-08-13 16:06:31.923 29017-29418/com.example.androidmysqltext001 W/System.err: at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:357) 2019-08-13 16:06:31.923 29017-29418/com.example.androidmysqltext001 W/System.err: at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:201) 2019-08-13 16:06:31.923 29017-29418/com.example.androidmysqltext001 W/System.err: at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:183) 2019-08-13 16:06:31.923 29017-29418/com.example.androidmysqltext001 W/System.err: at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:356) 2019-08-13 16:06:31.923 29017-29418/com.example.androidmysqltext001 W/System.err: at java.net.Socket.connect(Socket.java:616) 2019-08-13 16:06:31.923 29017-29418/com.example.androidmysqltext001 W/System.err: at java.net.Socket.connect(Socket.java:565) 2019-08-13 16:06:31.923 29017-29418/com.example.androidmysqltext001 W/System.err: at java.net.Socket.<init>(Socket.java:445) 2019-08-13 16:06:31.923 29017-29418/com.example.androidmysqltext001 W/System.err: at java.net.Socket.<init>(Socket.java:248) 2019-08-13 16:06:31.923 29017-29418/com.example.androidmysqltext001 W/System.err: at com.mysql.jdbc.StandardSocketFactory.connect(StandardSocketFactory.java:258) 2019-08-13 16:06:31.923 29017-29418/com.example.androidmysqltext001 W/System.err: at com.mysql.jdbc.MysqlIO.<init>(MysqlIO.java:306) 2019-08-13 16:06:31.923 29017-29418/com.example.androidmysqltext001 W/System.err: ... 14 more 2019-08-13 16:06:31.923 29017-29418/com.example.androidmysqltext001 W/System.err: Caused by: android.system.ErrnoException: connect failed: ETIMEDOUT (Connection timed out) 2019-08-13 16:06:31.923 29017-29418/com.example.androidmysqltext001 W/System.err: at libcore.io.Linux.connect(Native Method) 2019-08-13 16:06:31.923 29017-29418/com.example.androidmysqltext001 W/System.err: at libcore.io.BlockGuardOs.connect(BlockGuardOs.java:126) 2019-08-13 16:06:31.923 29017-29418/com.example.androidmysqltext001 W/System.err: at libcore.io.IoBridge.connectErrno(IoBridge.java:152) 2019-08-13 16:06:31.924 29017-29418/com.example.androidmysqltext001 W/System.err: at libcore.io.IoBridge.connect(IoBridge.java:130) 2019-08-13 16:06:31.924 29017-29418/com.example.androidmysqltext001 W/System.err: ... 25 more ```
Android连接SQLserver出现问题
我根据论坛的一个帖子的代码来改的注册界面,但是当传值时系统就崩溃了 显示No message resource found for message property prop.servertype 这是DButil的代码 public class DBUtil { private Connection connection; public static Connection getSQLConnection(String ip, String user, String pwd, String db) { Connection con = null; try { Class.forName("net.sourceforge.jtds.jdbc.Driver"); con = DriverManager.getConnection("jdbc:jtds:sqlserver://" + ip + ":1433/" + db, user, pwd); } catch (ClassNotFoundException e) { e.printStackTrace(); } catch (SQLException e) { e.printStackTrace(); } return con; } public static String QuerySQL(String UserName, String Name, String PassWord, String Email) { String result = ""; try { Connection connection = DBUtil.getSQLConnection("94.191.104.***", "sa", "123456", "txl"); String sql = "insert into tuser values(" + UserName + "," + Name + "," + PassWord + "," + Email + ");"; Statement stmt = connection.createStatement();// PreparedStatement stat = connection.prepareStatement(sql); ResultSet rs = stat.executeQuery();//执行查询语句 while (rs.next())//判断是否查询出数据 { result= "1" ; } stmt.close(); connection.close(); } catch (SQLException e) { e.printStackTrace(); result += "查询数据异常!" + e.getMessage(); } return result; } public void setConnection(Connection connection) { this.connection = connection; } } 这是注册界面的代码 public class SignActivity extends Activity { private TextView aUseName; private TextView aName; private TextView aPassWord; private TextView aRpassWord; private TextView aEmail; private Button bSign; private Handler handler; boolean isTip1=false,isTip2=false,isTip3=false,isTip4=false; @Override protected void onCreate( Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.sign); intView(); initListener(); WorkThread wt=new WorkThread(); wt.start(); } private void initListener() { bSign.setOnClickListener(new View.OnClickListener() { private Editable text; @Override public void onClick(View view) { String UserName = aUseName.getText().toString(); String Name = aName.getText().toString(); String PassWord = aPassWord.getText().toString(); String RpassWord = aRpassWord.getText().toString(); String Email = aEmail.getText().toString(); if (TextUtils.isEmpty(UserName)) {//用户名为空 aUseName.setError("用户名不能为空"); return; } //限制用户名长度在3-10位 if(UserName.length()>10||UserName.length()<3){ aUseName.setError("请输入3-10位数用户名"); return; }else { isTip1=true; } //限制输入密码长度在6-10位 if(PassWord.length()>10||PassWord.length()<6){ aPassWord.setError("请输入6-10位数密码"); return; }else { isTip2=true; } //限制昵称长度 if(Name.length()>7){ aPassWord.setError("请输入7位数以内昵称"); return; } //判断确认密码是否和密码相等 if (PassWord.equals(RpassWord)) {//确认密码和密码相等 isTip3=true; }else { //确认密码和密码不相等 aRpassWord.setError("两次输入密码不相等"); return; } //判断电子邮箱是否为空 if (TextUtils.isEmpty(Email)) {//电子邮箱为空 aEmail.setError("电子邮箱不能为空"); return; } //判断电子邮箱格式 if(Email.matches("[a-zA-Z0-9._-]+@[a-z0-9]+.[a-z]+")){ isTip4=true; }else{ aEmail.setError("电子邮箱格式不正确"); return; } if(isTip1==true&&isTip2==true&&isTip3==true&&isTip4==true) { Message m = handler.obtainMessage();//获取事件 Bundle b = new Bundle(); b.putString("Usename", UserName); b.putString("Name", Name);//以键值对形式放进 Bundle中 b.putString("Password", PassWord); b.putString("Email", Email); m.setData(b); m.what = 0; handler.sendMessage(m); } } }); } class WorkThread extends Thread{ @Override public void run(){ Looper.prepare(); handler = new Handler() { @Override public void handleMessage(Message m) { super.handleMessage(m); Bundle b = m.getData();//得到与信息对用的Bundle String Usename = b.getString("Usename");//根据键取值 String Name = b.getString("Name"); String Password = b.getString("Password");//根据键取值 String Email = b.getString("Email"); DBUtil db = new DBUtil();//调用数据库查询类 String ret = db.QuerySQL(Usename,Name,Password,Email);//得到返回值 if (ret.equals("1"))//为1,页面跳转,登陆成功 { Toast.makeText(SignActivity.this, "注册成功", Toast.LENGTH_SHORT).show(); } Toast.makeText(SignActivity.this, "注册失败", Toast.LENGTH_SHORT).show(); } }; Looper.loop();//Looper循环,通道中有数据执行,无数据堵塞 } } private void intView(){ aUseName =(TextView)findViewById(R.id.ausename); aName=(TextView)findViewById(R.id.aname); aPassWord=(TextView)findViewById(R.id.apassword); aRpassWord=(TextView)findViewById(R.id.arpassword); aEmail=(TextView)findViewById(R.id.aemail); bSign= findViewById(R.id.bsign); } }
推荐 130 个令你眼前一亮的网站,总有一个用得着
总结了大学生活两年来,发现的 130 余个黑科技网站,总有一个会让你眼前一亮,赶紧收藏!
在中国程序员是青春饭吗?
今年,我也32了 ,为了不给大家误导,咨询了猎头、圈内好友,以及年过35岁的几位老程序员……舍了老脸去揭人家伤疤……希望能给大家以帮助,记得帮我点赞哦。 目录: 你以为的人生 一次又一次的伤害 猎头界的真相 如何应对互联网行业的「中年危机」 一、你以为的人生 刚入行时,拿着傲人的工资,想着好好干,以为我们的人生是这样的: 等真到了那一天,你会发现,你的人生很可能是这样的: ...
我在支付宝花了1分钟,查到了女朋友的开房记录!
在大数据时代下,不管你做什么都会留下蛛丝马迹,只要学会把各种软件运用到极致,捉奸简直轻而易举。今天就来给大家分享一下,什么叫大数据抓出轨。据史料证明,马爸爸年轻时曾被...
程序员请照顾好自己,周末病魔差点一套带走我。
程序员在一个周末的时间,得了重病,差点当场去世,还好及时挽救回来了。
卸载 x 雷某度!GitHub 标星 1.5w+,从此我只用这款全能高速下载工具!
作者 | Rocky0429 来源 | Python空间 大家好,我是 Rocky0429,一个喜欢在网上收集各种资源的蒟蒻… 网上资源眼花缭乱,下载的方式也同样千奇百怪,比如 BT 下载,磁力链接,网盘资源等等等等,下个资源可真不容易,不一样的方式要用不同的下载软件,因此某比较有名的 x 雷和某度网盘成了我经常使用的工具。 作为一个没有钱的穷鬼,某度网盘几十 kb 的下载速度让我...
20道你必须要背会的微服务面试题,面试一定会被问到
写在前面: 在学习springcloud之前大家一定要先了解下,常见的面试题有那块,然后我们带着问题去学习这个微服务技术,那么就会更加理解springcloud技术。如果你已经学了springcloud,那么在准备面试的时候,一定要看看看这些面试题。 文章目录1、什么是微服务?2、微服务之间是如何通讯的?3、springcloud 与dubbo有哪些区别?4、请谈谈对SpringBoot 和S...
讲真,这两个IDE插件,可以让你写出质量杠杠的代码
周末躺在床上看《拯救大兵瑞恩》 周末在闲逛的时候,发现了两个优秀的 IDE 插件,据说可以提高代码的质量,我就安装了一下,试了试以后发现,确实很不错,就推荐给大家。 01、Alibaba Java 代码规范插件 《阿里巴巴 Java 开发手册》,相信大家都不会感到陌生,其 IDEA 插件的下载次数据说达到了 80 万次,我今天又贡献了一次。嘿嘿。 该项目的插件地址: https://github....
为什么猝死的都是程序员,基本上不见产品经理猝死呢?
相信大家时不时听到程序员猝死的消息,但是基本上听不到产品经理猝死的消息,这是为什么呢? 我们先百度搜一下:程序员猝死,出现将近700多万条搜索结果: 搜索一下:产品经理猝死,只有400万条的搜索结果,从搜索结果数量上来看,程序员猝死的搜索结果就比产品经理猝死的搜索结果高了一倍,而且从下图可以看到,首页里面的五条搜索结果,其实只有两条才是符合条件。 所以程序员猝死的概率真的比产品经理大,并不是错...
毕业5年,我问遍了身边的大佬,总结了他们的学习方法
我问了身边10个大佬,总结了他们的学习方法,原来成功都是有迹可循的。
推荐10个堪称神器的学习网站
每天都会收到很多读者的私信,问我:“二哥,有什么推荐的学习网站吗?最近很浮躁,手头的一些网站都看烦了,想看看二哥这里有什么新鲜货。” 今天一早做了个恶梦,梦到被老板辞退了。虽然说在我们公司,只有我辞退老板的份,没有老板辞退我这一说,但是还是被吓得 4 点多都起来了。(主要是因为我掌握着公司所有的核心源码,哈哈哈) 既然 4 点多起来,就得好好利用起来。于是我就挑选了 10 个堪称神器的学习网站,推...
这些软件太强了,Windows必装!尤其程序员!
Windows可谓是大多数人的生产力工具,集娱乐办公于一体,虽然在程序员这个群体中都说苹果是信仰,但是大部分不都是从Windows过来的,而且现在依然有很多的程序员用Windows。 所以,今天我就把我私藏的Windows必装的软件分享给大家,如果有一个你没有用过甚至没有听过,那你就赚了????,这可都是提升你幸福感的高效率生产力工具哦! 走起!???? NO、1 ScreenToGif 屏幕,摄像头和白板...
阿里面试,面试官没想到一个ArrayList,我都能跟他扯半小时
我是真的没想到,面试官会这样问我ArrayList。
曾经优秀的人,怎么就突然不优秀了。
职场上有很多辛酸事,很多合伙人出局的故事,很多技术骨干被裁员的故事。说来模板都类似,曾经是名校毕业,曾经是优秀员工,曾经被领导表扬,曾经业绩突出,然而突然有一天,因为种种原因,被裁员了,...
大学四年因为知道了这32个网站,我成了别人眼中的大神!
依稀记得,毕业那天,我们导员发给我毕业证的时候对我说“你可是咱们系的风云人物啊”,哎呀,别提当时多开心啦????,嗯,我们导员是所有导员中最帅的一个,真的???? 不过,导员说的是实话,很多人都叫我大神的,为啥,因为我知道这32个网站啊,你说强不强????,这次是绝对的干货,看好啦,走起来! PS:每个网站都是学计算机混互联网必须知道的,真的牛杯,我就不过多介绍了,大家自行探索,觉得没用的,尽管留言吐槽吧???? 社...
良心推荐,我珍藏的一些Chrome插件
上次搬家的时候,发了一个朋友圈,附带的照片中不小心暴露了自己的 Chrome 浏览器插件之多,于是就有小伙伴评论说分享一下我觉得还不错的浏览器插件。 我下面就把我日常工作和学习中经常用到的一些 Chrome 浏览器插件分享给大家,随便一个都能提高你的“生活品质”和工作效率。 Markdown Here Markdown Here 可以让你更愉快的写邮件,由于支持 Markdown 直接转电子邮...
看完这篇HTTP,跟面试官扯皮就没问题了
我是一名程序员,我的主要编程语言是 Java,我更是一名 Web 开发人员,所以我必须要了解 HTTP,所以本篇文章就来带你从 HTTP 入门到进阶,看完让你有一种恍然大悟、醍醐灌顶的感觉。 最初在有网络之前,我们的电脑都是单机的,单机系统是孤立的,我还记得 05 年前那会儿家里有个电脑,想打电脑游戏还得两个人在一个电脑上玩儿,及其不方便。我就想为什么家里人不让上网,我的同学 xxx 家里有网,每...
2020 年,大火的 Python 和 JavaScript 是否会被取而代之?
Python 和 JavaScript 是目前最火的两大编程语言,但是2020 年,什么编程语言将会取而代之呢? 作者 |Richard Kenneth Eng 译者 |明明如月,责编 | 郭芮 出品 | CSDN(ID:CSDNnews) 以下为译文: Python 和 JavaScript 是目前最火的两大编程语言。然而,他们不可能永远屹立不倒。最终,必将像其他编程语言一...
史上最全的IDEA快捷键总结
现在Idea成了主流开发工具,这篇博客对其使用的快捷键做了总结,希望对大家的开发工作有所帮助。
阿里程序员写了一个新手都写不出的低级bug,被骂惨了。
这种新手都不会范的错,居然被一个工作好几年的小伙子写出来,差点被当场开除了。
谁是华为扫地僧?
是的,华为也有扫地僧!2020年2月11-12日,“养在深闺人不知”的华为2012实验室扫地僧们,将在华为开发者大会2020(Cloud)上,和大家见面。到时,你可以和扫地僧们,吃一个洋...
Flutter 会不会被苹果限制其发展?
这个可能性是存在的,而且不止是 flutter、react-native 、weex 、uni-app 、taro 、Hippy等都存在这个风险,虽然有些框架对比起 flutter 其他框架存在时间稍长,但是这不可否认它们一直都存在这个风向。 只要不是平台自己的亲儿子,那么肯定存在被限制发展的风险,所以这件事上是风险和收益之间的博弈,这是一个“后妈和前任之间的太极。” 先说现状 如今各大平台,如:...
Idea 中最常用的10款插件(提高开发效率),一定要学会使用!
学习使用一些插件,可以提高开发效率。对于我们开发人员很有帮助。这篇博客介绍了开发中使用的插件。
AI 没让人类失业,搞 AI 的人先失业了
最近和几个 AI 领域的大佬闲聊 根据他们讲的消息和段子 改编出下面这个故事 如有雷同 都是巧合 1. 老王创业失败,被限制高消费 “这里写我跑路的消息实在太夸张了。” 王葱葱哼笑一下,把消息分享给群里。 阿杰也看了消息,笑了笑。在座几位也都笑了。 王葱葱是个有名的人物,21岁那年以全额奖学金进入 KMU 攻读人工智能博士,累计发表论文 40 余篇,个人技术博客更是成为深度学习领域内风向标。 ...
2020年,冯唐49岁:我给20、30岁IT职场年轻人的建议
点击“技术领导力”关注∆每天早上8:30推送 作者|Mr.K 编辑| Emma 来源|技术领导力(ID:jishulingdaoli) 前天的推文《冯唐:职场人35岁以后,方法论比经验重要》,收到了不少读者的反馈,觉得挺受启发。其实,冯唐写了不少关于职场方面的文章,都挺不错的。可惜大家只记住了“春风十里不如你”、“如何避免成为油腻腻的中年人”等不那么正经的文章。 本文整理了冯...
最全最强!世界大学计算机专业排名总结!
我正在参与CSDN200进20,希望得到您的支持,扫码续投票5次。感谢您! (为表示感谢,您投票后私信我,我把我总结的人工智能手推笔记和思维导图发送给您,感谢!) 目录 泰晤士高等教育世界大学排名 QS 世界大学排名 US News 世界大学排名 世界大学学术排名(Academic Ranking of World Universities) 泰晤士高等教育世界大学排名 中国共...
作为一名大学生,如何在B站上快乐的学习?
B站是个宝,谁用谁知道???? 作为一名大学生,你必须掌握的一项能力就是自学能力,很多看起来很牛X的人,你可以了解下,人家私底下一定是花大量的时间自学的,你可能会说,我也想学习啊,可是嘞,该学习啥嘞,不怕告诉你,互联网时代,最不缺的就是学习资源,最宝贵的是啥? 你可能会说是时间,不,不是时间,而是你的注意力,懂了吧! 那么,你说学习资源多,我咋不知道,那今天我就告诉你一个你必须知道的学习的地方,人称...
那些年,我们信了课本里的那些鬼话
教材永远都是有错误的,从小学到大学,我们不断的学习了很多错误知识。 斑羚飞渡 在我们学习的很多小学课文里,有很多是错误文章,或者说是假课文。像《斑羚飞渡》: 随着镰刀头羊的那声吼叫,整个斑羚群迅速分成两拨,老年斑羚为一拨,年轻斑羚为一拨。 就在这时,我看见,从那拨老斑羚里走出一只公斑羚来。公斑羚朝那拨年轻斑羚示意性地咩了一声,一只半大的斑羚应声走了出来。一老一少走到伤心崖,后退了几步,突...
一个程序在计算机中是如何运行的?超级干货!!!
强烈声明:本文很干,请自备茶水!???? 开门见山,咱不说废话! 你有没有想过,你写的程序,是如何在计算机中运行的吗?比如我们搞Java的,肯定写过这段代码 public class HelloWorld { public static void main(String[] args) { System.out.println("Hello World!"); } ...
【蘑菇街技术部年会】程序员与女神共舞,鼻血再次没止住。(文末内推)
蘑菇街技术部的年会,别开生面,一样全是美女。
Linux必懂知识大总结(补)
关机 1. 数据同步写入磁盘 sync 为了加快对磁盘上文件的读写速度,位于内存中的文件数据不会立即同步到磁盘上,因此关机之前需要先进行 sync 同步操作。 2. shutdown # /sbin/shutdown [-krhc] [时间] [警告讯息] -k : 不会关机,只是发送警告讯息,通知所有在线的用户 -r : 将系统的服务停掉后就重新启动 -h : 将系统的服务停掉后就...
那个在阿里养猪的工程师,5年了……
简介: 在阿里,走过1825天,没有趴下,依旧斗志满满,被称为“五年陈”。他们会被授予一枚戒指,过程就叫做“授戒仪式”。今天,咱们听听阿里的那些“五年陈”们的故事。 下一个五年,猪圈见! 我就是那个在养猪场里敲代码的工程师,一年多前我和20位工程师去了四川的猪场,出发前总架构师慷慨激昂的说:同学们,中国的养猪产业将因为我们而改变。但到了猪场,发现根本不是那么回事:要个WIFI,没有;...
为什么程序猿都不愿意去外包?
分享外包的组织架构,盈利模式,亲身经历,以及根据一些外包朋友的反馈,写了这篇文章 ,希望对正在找工作的老铁有所帮助
Java校招入职华为,半年后我跑路了
何来 我,一个双非本科弟弟,有幸在 19 届的秋招中得到前东家华为(以下简称 hw)的赏识,当时秋招签订就业协议,说是入了某 java bg,之后一系列组织架构调整原因等等让人无法理解的神操作,最终毕业前夕,被通知调往其他 bg 做嵌入式开发(纯 C 语言)。 由于已至于校招末尾,之前拿到的其他 offer 又无法再收回,一时感到无力回天,只得默默接受。 毕业后,直接入职开始了嵌入式苦旅,由于从未...
立即提问