Tuy nhiên, vì nó là một yêu cầu khá phổ biến, chúng tôi sẽ nghiên cứu kỹ vào nguồn dữ liệu bởi vì bạn chắc chắn sẽ cần phải cấu hình chúng, cộng thêm, họ sẽ giúp bạn phát triển kiến thức của bạn của môi trường. | CHAPTER 2 GETTING STARTED WITH GRAILS 35 However since it is a pretty common requirement we will delve into data sources because you ll certainly need to configure them plus they ll help you develop your knowledge of environments. The File When you create a Grails application Grails automatically provides a grails-app conf file that contains configuration for each environment see Figure 2-11 . You might find this convenient because it means most of the work is done for you but you might prefer to use another database such as MySQL rather than the provided HSQLDB database. Figure 2-11. The file Defining a data source is one area where the strength of the Java platform becomes apparent. Java s database connectivity technology JDBC is extremely mature with drivers available for pretty much every database on the market. In fact if a database provider does not deliver high-quality stable JDBC drivers its product is unlikely to be taken seriously in the marketplace. A data-source definition is translated into a instance that supplies JDBC Connection objects. If you ve used JDBC before the process will be familiar with the first step ensuring that the driver classes normally packaged within a JAR archive are available on the classpath. 36 CHAPTER 2 GETTING STARTED WITH GRAILS The DataSource .groovy file contains some common configuration setup at the top of the data-source definition an example of which is presented in Listing 2-20. Listing 2-20. Common Data-Source Configuration dataSource pooled true driverClassName username sa password The snippet indicates that by default you want a pooled data source using the HSQLDB driver with a username of sa and a blank password. You could apply defaults to several other settings. Here s a list of the settings that the file provides driverClassName This is the class name of the JDBC driver. username This is the .