String databaseUrl = "jdbc:mysql://localhost:3306/mydatabase"; String username = "myusername"; String password = "mypassword"; ConnectionSource connectionSource = new JdbcConnectionSource(databaseUrl, username, password); Dao<YourEntity, Integer> dao = DaoManager.createDao(connectionSource, YourEntity.class); TableUtils.createTableIfNotExists(connectionSource, YourEntity.class); Dao<YourEntity, Integer> dao = DaoManager.createDao(connectionSource, YourEntity.class); List<YourEntity> entities = dao.queryForAll(); Dao<YourEntity, Integer> dao = DaoManager.createDao(connectionSource, YourEntity.class); YourEntity newEntity = new YourEntity(); dao.create(newEntity); newEntity.setSomeField("new value"); dao.update(newEntity); dao.delete(newEntity);


上一篇:
下一篇:
切换中文